feat: roles, permissions
This commit is contained in:
@@ -63,7 +63,7 @@ func AuthMiddleware() fiber.Handler {
|
||||
// Set user in context
|
||||
c.Locals(constdata.USER_LOCALES_NAME, user.ToSession())
|
||||
c.Locals(constdata.USER_LOCALES_ID, user.ID)
|
||||
|
||||
c.Locals(constdata.LANG_LOCALES_ID, user.LangID)
|
||||
return c.Next()
|
||||
}
|
||||
}
|
||||
@@ -85,7 +85,7 @@ func RequireAdmin() fiber.Handler {
|
||||
})
|
||||
}
|
||||
|
||||
if userSession.Role != model.RoleAdmin {
|
||||
if model.CustomerRole(userSession.RoleName) != model.RoleAdmin {
|
||||
return c.Status(fiber.StatusForbidden).JSON(fiber.Map{
|
||||
"error": "admin access required",
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user