Better handling of permissions
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user