new page layout
This commit is contained in:
@@ -135,6 +135,28 @@ func (store *Store) DeleteUser(ctx *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
store.DB.Delete(&user)
|
||||
tx := store.DB.Delete(&user)
|
||||
if tx.Error != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, tx.Error.Error())
|
||||
return
|
||||
}
|
||||
|
||||
ctx.SetCookie(
|
||||
"access_token",
|
||||
"",
|
||||
-1,
|
||||
store.Auth.Config.Endpoint,
|
||||
store.Auth.Config.Domain,
|
||||
true, true,
|
||||
)
|
||||
ctx.SetCookie(
|
||||
"refresh_token",
|
||||
"",
|
||||
-1,
|
||||
store.Auth.Config.Endpoint,
|
||||
store.Auth.Config.Domain,
|
||||
true, true,
|
||||
)
|
||||
|
||||
ctx.JSON(http.StatusOK, user)
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ import "gorm.io/gorm"
|
||||
|
||||
type Post struct {
|
||||
gorm.Model // includes ID, CreatedAt, UpdatedAt, DeletedAt
|
||||
Title string `gorm:"not null"`
|
||||
AuthorID uint
|
||||
Author User `gorm:"foreignKey:AuthorID"`
|
||||
Content string
|
||||
Title string `gorm:"not null" json:"title"`
|
||||
AuthorID uint `json:"-"`
|
||||
Author User `gorm:"foreignKey:AuthorID" json:"author"`
|
||||
Content string `json:"content"`
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import "gorm.io/gorm"
|
||||
|
||||
type User struct {
|
||||
gorm.Model // includes ID, CreatedAt, UpdatedAt, DeletedAt
|
||||
Username string `gorm:"uniqueIndex"`
|
||||
Username string `gorm:"uniqueIndex" json:"username"`
|
||||
Password []byte `json:"-"`
|
||||
Admin bool
|
||||
Admin bool `json:"admin"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user