Better handling of permissions

This commit is contained in:
cdricms
2025-01-31 13:07:25 +01:00
parent acfd2c7b14
commit f7dd0c60d6
12 changed files with 45 additions and 57 deletions

View File

@@ -159,24 +159,6 @@ func HasPermissions(resource string, actions ...string) core.Middleware {
return
}
// permissions := utils.MergeArrays(
// utils.Map(user.Roles, func(r models.Role) []models.Permission {
// return r.Permissions
// })...)
//
// for _, action := range actions {
// permission := utils.Find(permissions, func(p models.Permission, i int) bool {
// return resource == p.Resource && action == p.Action
// })
// if permission == nil {
// core.JSONError{
// Status: core.Error,
// Message: fmt.Sprintf("The user doesn't have the proper permission %s:%s", resource, action),
// }.Respond(w, http.StatusUnauthorized)
// return
// }
// }
permissionsSet := make(map[string]struct{}) // Set to store unique permissions
// Populate the set with user's permissions