Fix 404 & clean code
This commit is contained in:
parent
6b27dd545a
commit
68edf0a76f
9 changed files with 192 additions and 184 deletions
|
|
@ -90,9 +90,9 @@ func AccountManage(c *fiber.Ctx) error {
|
|||
result = db.Save(&user)
|
||||
if result.Error != nil {
|
||||
return result.Error
|
||||
} else {
|
||||
c.Redirect("/account/manage")
|
||||
}
|
||||
|
||||
c.Redirect("/account/manage")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -307,14 +307,14 @@ func ContactEdit(c *fiber.Ctx) error {
|
|||
var person models.Person
|
||||
result := db.Find(&person, "id = ?", id)
|
||||
|
||||
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
||||
return fiber.NewError(fiber.StatusNotFound, "Not found")
|
||||
}
|
||||
|
||||
if result.Error != nil {
|
||||
return result.Error
|
||||
}
|
||||
|
||||
if result.RowsAffected < 1 {
|
||||
return fiber.NewError(fiber.StatusNotFound, "Not found")
|
||||
}
|
||||
|
||||
title := fmt.Sprintf(
|
||||
"%s %s | Modifier contact",
|
||||
person.LastName,
|
||||
|
|
@ -549,14 +549,14 @@ func ContactConvert(c *fiber.Ctx) error {
|
|||
var person models.Person
|
||||
result := db.Find(&person, "id = ?", id)
|
||||
|
||||
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
||||
return fiber.NewError(fiber.StatusNotFound, "Not found")
|
||||
}
|
||||
|
||||
if result.Error != nil {
|
||||
return result.Error
|
||||
}
|
||||
|
||||
if result.RowsAffected < 1 {
|
||||
return fiber.NewError(fiber.StatusNotFound, "Not found")
|
||||
}
|
||||
|
||||
person.IsContact = false
|
||||
person.IsMember = true
|
||||
|
||||
|
|
|
|||
|
|
@ -43,14 +43,14 @@ func FieldShow(c *fiber.Ctx) error {
|
|||
var field models.Field
|
||||
result := db.Preload("List").Find(&field, "id = ?", id)
|
||||
|
||||
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
||||
return fiber.NewError(fiber.StatusNotFound, "Not found")
|
||||
}
|
||||
|
||||
if result.Error != nil {
|
||||
return result.Error
|
||||
}
|
||||
|
||||
if result.RowsAffected < 1 {
|
||||
return fiber.NewError(fiber.StatusNotFound, "Not found")
|
||||
}
|
||||
|
||||
title := fmt.Sprintf(
|
||||
"%s | Champs supplémentaires",
|
||||
field.Name,
|
||||
|
|
@ -115,12 +115,12 @@ func FieldAdd(c *fiber.Ctx) error {
|
|||
result := db.Create(&field)
|
||||
if result.Error != nil {
|
||||
return result.Error
|
||||
} else {
|
||||
c.Redirect(fmt.Sprintf(
|
||||
"/admin/fields/%d",
|
||||
field.ID,
|
||||
))
|
||||
}
|
||||
|
||||
c.Redirect(fmt.Sprintf(
|
||||
"/admin/fields/%d",
|
||||
field.ID,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -145,14 +145,14 @@ func FieldEdit(c *fiber.Ctx) error {
|
|||
var field models.Field
|
||||
result := db.Find(&field, "id = ?", id)
|
||||
|
||||
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
||||
return fiber.NewError(fiber.StatusNotFound, "Not found")
|
||||
}
|
||||
|
||||
if result.Error != nil {
|
||||
return result.Error
|
||||
}
|
||||
|
||||
if result.RowsAffected < 1 {
|
||||
return fiber.NewError(fiber.StatusNotFound, "Not found")
|
||||
}
|
||||
|
||||
title := fmt.Sprintf(
|
||||
"%s | Modifier un champ",
|
||||
field.Name,
|
||||
|
|
@ -169,12 +169,12 @@ func FieldEdit(c *fiber.Ctx) error {
|
|||
result := db.Save(&field)
|
||||
if result.Error != nil {
|
||||
return result.Error
|
||||
} else {
|
||||
c.Redirect(fmt.Sprintf(
|
||||
"/admin/fields/%d",
|
||||
field.ID,
|
||||
))
|
||||
}
|
||||
|
||||
c.Redirect(fmt.Sprintf(
|
||||
"/admin/fields/%d",
|
||||
field.ID,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,14 +40,14 @@ func ListShow(c *fiber.Ctx) error {
|
|||
var list models.List
|
||||
result := db.Find(&list, "id = ?", id)
|
||||
|
||||
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
||||
return fiber.NewError(fiber.StatusNotFound, "Not found")
|
||||
}
|
||||
|
||||
if result.Error != nil {
|
||||
return result.Error
|
||||
}
|
||||
|
||||
if result.RowsAffected < 1 {
|
||||
return fiber.NewError(fiber.StatusNotFound, "Not found")
|
||||
}
|
||||
|
||||
title := fmt.Sprintf(
|
||||
"%s | Listes",
|
||||
list.Name,
|
||||
|
|
@ -90,12 +90,12 @@ func ListAdd(c *fiber.Ctx) error {
|
|||
result := db.Create(&list)
|
||||
if result.Error != nil {
|
||||
return result.Error
|
||||
} else {
|
||||
c.Redirect(fmt.Sprintf(
|
||||
"/admin/lists/%d",
|
||||
list.ID,
|
||||
))
|
||||
}
|
||||
|
||||
c.Redirect(fmt.Sprintf(
|
||||
"/admin/lists/%d",
|
||||
list.ID,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -117,14 +117,14 @@ func ListEdit(c *fiber.Ctx) error {
|
|||
var list models.List
|
||||
result := db.Find(&list, "id = ?", id)
|
||||
|
||||
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
||||
return fiber.NewError(fiber.StatusNotFound, "Not found")
|
||||
}
|
||||
|
||||
if result.Error != nil {
|
||||
return result.Error
|
||||
}
|
||||
|
||||
if result.RowsAffected < 1 {
|
||||
return fiber.NewError(fiber.StatusNotFound, "Not found")
|
||||
}
|
||||
|
||||
title := fmt.Sprintf(
|
||||
"%s | Modifier liste",
|
||||
list.Name,
|
||||
|
|
@ -148,29 +148,29 @@ func ListEdit(c *fiber.Ctx) error {
|
|||
}
|
||||
|
||||
if len(errors) == 0 {
|
||||
result := db.Save(&list)
|
||||
result = db.Save(&list)
|
||||
if result.Error != nil {
|
||||
return result.Error
|
||||
} else {
|
||||
if !list.Multi && multiOriginal {
|
||||
var listItems []models.ListItem
|
||||
result2 := db.Find(&listItems,
|
||||
"list_id = ? AND `default` = ?",
|
||||
list.ID, true,
|
||||
)
|
||||
|
||||
if result2.RowsAffected > 1 {
|
||||
db.Model(&models.ListItem{}).Where(
|
||||
"list_id = ?", list.ID,
|
||||
).Update("default", false)
|
||||
}
|
||||
}
|
||||
|
||||
c.Redirect(fmt.Sprintf(
|
||||
"/admin/lists/%d",
|
||||
list.ID,
|
||||
))
|
||||
}
|
||||
|
||||
if !list.Multi && multiOriginal {
|
||||
var listItems []models.ListItem
|
||||
result = db.Find(&listItems,
|
||||
"list_id = ? AND `default` = ?",
|
||||
list.ID, true,
|
||||
)
|
||||
|
||||
if result.RowsAffected > 1 {
|
||||
db.Model(&models.ListItem{}).Where(
|
||||
"list_id = ?", list.ID,
|
||||
).Update("default", false)
|
||||
}
|
||||
}
|
||||
|
||||
c.Redirect(fmt.Sprintf(
|
||||
"/admin/lists/%d",
|
||||
list.ID,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -208,14 +208,14 @@ func ListItemAdd(c *fiber.Ctx) error {
|
|||
var list models.List
|
||||
result := db.Find(&list, "id = ?", id)
|
||||
|
||||
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
||||
return fiber.NewError(fiber.StatusNotFound, "Not found")
|
||||
}
|
||||
|
||||
if result.Error != nil {
|
||||
return result.Error
|
||||
}
|
||||
|
||||
if result.RowsAffected < 1 {
|
||||
return fiber.NewError(fiber.StatusNotFound, "Not found")
|
||||
}
|
||||
|
||||
title := fmt.Sprintf(
|
||||
"%s | Ajouter un élément à la liste",
|
||||
list.Name,
|
||||
|
|
@ -244,19 +244,19 @@ func ListItemAdd(c *fiber.Ctx) error {
|
|||
result := db.Create(&listItem)
|
||||
if result.Error != nil {
|
||||
return result.Error
|
||||
} else {
|
||||
if listItem.Default && !list.Multi {
|
||||
db.Model(&models.ListItem{}).Where(
|
||||
"list_id = ? AND id <> ?",
|
||||
list.ID, listItem.ID,
|
||||
).Update("default", false)
|
||||
}
|
||||
|
||||
c.Redirect(fmt.Sprintf(
|
||||
"/admin/lists/%d",
|
||||
list.ID,
|
||||
))
|
||||
}
|
||||
|
||||
if listItem.Default && !list.Multi {
|
||||
db.Model(&models.ListItem{}).Where(
|
||||
"list_id = ? AND id <> ?",
|
||||
list.ID, listItem.ID,
|
||||
).Update("default", false)
|
||||
}
|
||||
|
||||
c.Redirect(fmt.Sprintf(
|
||||
"/admin/lists/%d",
|
||||
list.ID,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -280,25 +280,25 @@ func ListItemEdit(c *fiber.Ctx) error {
|
|||
var list models.List
|
||||
result := db.Find(&list, "id = ?", id)
|
||||
|
||||
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
||||
if result.Error != nil {
|
||||
return result.Error
|
||||
}
|
||||
|
||||
if result.RowsAffected < 1 {
|
||||
return fiber.NewError(fiber.StatusNotFound, "Not found")
|
||||
}
|
||||
|
||||
var listItem models.ListItem
|
||||
result = db.Find(&listItem, "id = ?", itemid)
|
||||
|
||||
if result.Error != nil {
|
||||
return result.Error
|
||||
}
|
||||
|
||||
var listItem models.ListItem
|
||||
result2 := db.Find(&listItem, "id = ?", itemid)
|
||||
|
||||
if errors.Is(result2.Error, gorm.ErrRecordNotFound) {
|
||||
if result.RowsAffected < 1 {
|
||||
return fiber.NewError(fiber.StatusNotFound, "Not found")
|
||||
}
|
||||
|
||||
if result2.Error != nil {
|
||||
return result2.Error
|
||||
}
|
||||
|
||||
title := fmt.Sprintf(
|
||||
"%s | Modifier un élément de la liste",
|
||||
list.Name,
|
||||
|
|
@ -320,22 +320,22 @@ func ListItemEdit(c *fiber.Ctx) error {
|
|||
}
|
||||
|
||||
if len(errors) == 0 {
|
||||
result3 := db.Save(&listItem)
|
||||
if result3.Error != nil {
|
||||
return result3.Error
|
||||
} else {
|
||||
if listItem.Default && !list.Multi {
|
||||
db.Model(&models.ListItem{}).Where(
|
||||
"list_id = ? AND id <> ?",
|
||||
list.ID, listItem.ID,
|
||||
).Update("default", false)
|
||||
}
|
||||
|
||||
c.Redirect(fmt.Sprintf(
|
||||
"/admin/lists/%d",
|
||||
list.ID,
|
||||
))
|
||||
result = db.Save(&listItem)
|
||||
if result.Error != nil {
|
||||
return result.Error
|
||||
}
|
||||
|
||||
if listItem.Default && !list.Multi {
|
||||
db.Model(&models.ListItem{}).Where(
|
||||
"list_id = ? AND id <> ?",
|
||||
list.ID, listItem.ID,
|
||||
).Update("default", false)
|
||||
}
|
||||
|
||||
c.Redirect(fmt.Sprintf(
|
||||
"/admin/lists/%d",
|
||||
list.ID,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -359,17 +359,17 @@ func ListItemDelete(c *fiber.Ctx) error {
|
|||
var list models.List
|
||||
result := db.Find(&list, "id = ?", id)
|
||||
|
||||
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
||||
return fiber.NewError(fiber.StatusNotFound, "Not found")
|
||||
}
|
||||
|
||||
if result.Error != nil {
|
||||
return result.Error
|
||||
}
|
||||
|
||||
result2 := db.Delete(&models.ListItem{}, itemid)
|
||||
if result2.Error != nil {
|
||||
return result2.Error
|
||||
if result.RowsAffected < 1 {
|
||||
return fiber.NewError(fiber.StatusNotFound, "Not found")
|
||||
}
|
||||
|
||||
result = db.Delete(&models.ListItem{}, itemid)
|
||||
if result.Error != nil {
|
||||
return result.Error
|
||||
}
|
||||
|
||||
return c.Redirect(fmt.Sprintf(
|
||||
|
|
|
|||
|
|
@ -40,14 +40,14 @@ func RoleShow(c *fiber.Ctx) error {
|
|||
var role models.Role
|
||||
result := db.Find(&role, "id = ?", id)
|
||||
|
||||
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
||||
return fiber.NewError(fiber.StatusNotFound, "Not found")
|
||||
}
|
||||
|
||||
if result.Error != nil {
|
||||
return result.Error
|
||||
}
|
||||
|
||||
if result.RowsAffected < 1 {
|
||||
return fiber.NewError(fiber.StatusNotFound, "Not found")
|
||||
}
|
||||
|
||||
title := fmt.Sprintf(
|
||||
"%s | Rôles",
|
||||
role.Name,
|
||||
|
|
@ -100,12 +100,12 @@ func RoleAdd(c *fiber.Ctx) error {
|
|||
result := db.Create(&role)
|
||||
if result.Error != nil {
|
||||
return result.Error
|
||||
} else {
|
||||
c.Redirect(fmt.Sprintf(
|
||||
"/admin/roles/%d",
|
||||
role.ID,
|
||||
))
|
||||
}
|
||||
|
||||
c.Redirect(fmt.Sprintf(
|
||||
"/admin/roles/%d",
|
||||
role.ID,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -127,14 +127,14 @@ func RoleEdit(c *fiber.Ctx) error {
|
|||
var role models.Role
|
||||
result := db.Find(&role, "id = ?", id)
|
||||
|
||||
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
||||
return fiber.NewError(fiber.StatusNotFound, "Not found")
|
||||
}
|
||||
|
||||
if result.Error != nil {
|
||||
return result.Error
|
||||
}
|
||||
|
||||
if result.RowsAffected < 1 {
|
||||
return fiber.NewError(fiber.StatusNotFound, "Not found")
|
||||
}
|
||||
|
||||
title := fmt.Sprintf(
|
||||
"%s | Modifier rôle",
|
||||
role.Name,
|
||||
|
|
@ -173,12 +173,12 @@ func RoleEdit(c *fiber.Ctx) error {
|
|||
result := db.Save(&role)
|
||||
if result.Error != nil {
|
||||
return result.Error
|
||||
} else {
|
||||
c.Redirect(fmt.Sprintf(
|
||||
"/admin/roles/%d",
|
||||
role.ID,
|
||||
))
|
||||
}
|
||||
|
||||
c.Redirect(fmt.Sprintf(
|
||||
"/admin/roles/%d",
|
||||
role.ID,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,14 +41,14 @@ func SectionShow(c *fiber.Ctx) error {
|
|||
var section models.Section
|
||||
result := db.Preload("ParentSection").Find(§ion, "id = ?", id)
|
||||
|
||||
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
||||
return fiber.NewError(fiber.StatusNotFound, "Not found")
|
||||
}
|
||||
|
||||
if result.Error != nil {
|
||||
return result.Error
|
||||
}
|
||||
|
||||
if result.RowsAffected < 1 {
|
||||
return fiber.NewError(fiber.StatusNotFound, "Not found")
|
||||
}
|
||||
|
||||
title := fmt.Sprintf(
|
||||
"%s | Sections",
|
||||
section.Name,
|
||||
|
|
@ -131,12 +131,12 @@ func SectionAdd(c *fiber.Ctx) error {
|
|||
result := db.Create(§ion)
|
||||
if result.Error != nil {
|
||||
return result.Error
|
||||
} else {
|
||||
c.Redirect(fmt.Sprintf(
|
||||
"/admin/sections/%d",
|
||||
section.ID,
|
||||
))
|
||||
}
|
||||
|
||||
c.Redirect(fmt.Sprintf(
|
||||
"/admin/sections/%d",
|
||||
section.ID,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -159,14 +159,14 @@ func SectionEdit(c *fiber.Ctx) error {
|
|||
var section models.Section
|
||||
result := db.Find(§ion, "id = ?", id)
|
||||
|
||||
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
||||
return fiber.NewError(fiber.StatusNotFound, "Not found")
|
||||
}
|
||||
|
||||
if result.Error != nil {
|
||||
return result.Error
|
||||
}
|
||||
|
||||
if result.RowsAffected < 1 {
|
||||
return fiber.NewError(fiber.StatusNotFound, "Not found")
|
||||
}
|
||||
|
||||
var childSections []models.Section
|
||||
db.Find(&childSections, "parent_section_id = ?", section.ID)
|
||||
isParent := (len(childSections) > 0)
|
||||
|
|
@ -225,12 +225,12 @@ func SectionEdit(c *fiber.Ctx) error {
|
|||
result := db.Save(§ion)
|
||||
if result.Error != nil {
|
||||
return result.Error
|
||||
} else {
|
||||
c.Redirect(fmt.Sprintf(
|
||||
"/admin/sections/%d",
|
||||
section.ID,
|
||||
))
|
||||
}
|
||||
|
||||
c.Redirect(fmt.Sprintf(
|
||||
"/admin/sections/%d",
|
||||
section.ID,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,14 +48,14 @@ func UserShow(c *fiber.Ctx) error {
|
|||
var user models.User
|
||||
result := db.Find(&user, "id = ?", id)
|
||||
|
||||
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
||||
return fiber.NewError(fiber.StatusNotFound, "Not found")
|
||||
}
|
||||
|
||||
if result.Error != nil {
|
||||
return result.Error
|
||||
}
|
||||
|
||||
if result.RowsAffected < 1 {
|
||||
return fiber.NewError(fiber.StatusNotFound, "Not found")
|
||||
}
|
||||
|
||||
title := fmt.Sprintf(
|
||||
"%s | Utilisateurs",
|
||||
user.Name,
|
||||
|
|
@ -132,12 +132,12 @@ func UserAdd(c *fiber.Ctx) error {
|
|||
result = db.Create(&user)
|
||||
if result.Error != nil {
|
||||
return result.Error
|
||||
} else {
|
||||
c.Redirect(fmt.Sprintf(
|
||||
"/admin/users/%d",
|
||||
user.ID,
|
||||
))
|
||||
}
|
||||
|
||||
c.Redirect(fmt.Sprintf(
|
||||
"/admin/users/%d",
|
||||
user.ID,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -159,14 +159,14 @@ func UserEdit(c *fiber.Ctx) error {
|
|||
var user models.User
|
||||
result := db.Find(&user, "id = ?", id)
|
||||
|
||||
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
||||
return fiber.NewError(fiber.StatusNotFound, "Not found")
|
||||
}
|
||||
|
||||
if result.Error != nil {
|
||||
return result.Error
|
||||
}
|
||||
|
||||
if result.RowsAffected < 1 {
|
||||
return fiber.NewError(fiber.StatusNotFound, "Not found")
|
||||
}
|
||||
|
||||
title := fmt.Sprintf(
|
||||
"%s | Modifier utilisateur",
|
||||
user.Name,
|
||||
|
|
@ -240,15 +240,15 @@ func UserEdit(c *fiber.Ctx) error {
|
|||
}
|
||||
|
||||
if len(errors) == 0 {
|
||||
result2 := db.Save(&user)
|
||||
if result2.Error != nil {
|
||||
return result2.Error
|
||||
} else {
|
||||
c.Redirect(fmt.Sprintf(
|
||||
"/admin/users/%d",
|
||||
user.ID,
|
||||
))
|
||||
result = db.Save(&user)
|
||||
if result.Error != nil {
|
||||
return result.Error
|
||||
}
|
||||
|
||||
c.Redirect(fmt.Sprintf(
|
||||
"/admin/users/%d",
|
||||
user.ID,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -270,14 +270,14 @@ func UserPermissions(c *fiber.Ctx) error {
|
|||
var user models.User
|
||||
result := db.Find(&user, "id = ?", id)
|
||||
|
||||
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
||||
return fiber.NewError(fiber.StatusNotFound, "Not found")
|
||||
}
|
||||
|
||||
if result.Error != nil {
|
||||
return result.Error
|
||||
}
|
||||
|
||||
if result.RowsAffected < 1 {
|
||||
return fiber.NewError(fiber.StatusNotFound, "Not found")
|
||||
}
|
||||
|
||||
title := fmt.Sprintf(
|
||||
"%s | Permissions utilisateur",
|
||||
user.Name,
|
||||
|
|
@ -325,15 +325,15 @@ func UserPermissions(c *fiber.Ctx) error {
|
|||
}
|
||||
|
||||
if len(errors) == 0 {
|
||||
result2 := db.Save(&user)
|
||||
if result2.Error != nil {
|
||||
return result2.Error
|
||||
} else {
|
||||
c.Redirect(fmt.Sprintf(
|
||||
"/admin/users/%d",
|
||||
user.ID,
|
||||
))
|
||||
result = db.Save(&user)
|
||||
if result.Error != nil {
|
||||
return result.Error
|
||||
}
|
||||
|
||||
c.Redirect(fmt.Sprintf(
|
||||
"/admin/users/%d",
|
||||
user.ID,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -386,14 +386,14 @@ func UserDelete(c *fiber.Ctx) error {
|
|||
user.IsAdmin = false
|
||||
user.SkipWelcome = false
|
||||
|
||||
result2 := db.Save(&user)
|
||||
if result2.Error != nil {
|
||||
return result2.Error
|
||||
result = db.Save(&user)
|
||||
if result.Error != nil {
|
||||
return result.Error
|
||||
}
|
||||
|
||||
result3 := db.Delete(&models.User{}, id)
|
||||
if result3.Error != nil {
|
||||
return result3.Error
|
||||
result = db.Delete(&models.User{}, id)
|
||||
if result.Error != nil {
|
||||
return result.Error
|
||||
}
|
||||
|
||||
return c.Redirect("/admin/users")
|
||||
|
|
|
|||
|
|
@ -26,6 +26,10 @@ func FirstAccountCheck() (bool, error) {
|
|||
return false, result.Error
|
||||
}
|
||||
|
||||
if result.RowsAffected < 1 {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
return true, nil
|
||||
}
|
||||
|
||||
|
|
@ -72,6 +76,10 @@ func UserExistsAndIsActive(id uint) (bool, error) {
|
|||
return false, result.Error
|
||||
}
|
||||
|
||||
if result.RowsAffected < 1 {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
return true, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ func SavedSessionMiddleware(c *fiber.Ctx) error {
|
|||
time.Now(),
|
||||
)
|
||||
|
||||
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
||||
if errors.Is(result.Error, gorm.ErrRecordNotFound) || result.RowsAffected < 1 {
|
||||
c.ClearCookie("saved-session-uuid")
|
||||
c.ClearCookie("saved-session-secret")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue