-
-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
manage user permissions #514
base: main
Are you sure you want to change the base?
Conversation
Hey @dwradcliffe , just wanted to check in. Did you want me to review your PR, or is it still under development? |
user.Permissions = make(map[string]map[string]bool) | ||
|
||
for _, acl := range acls { | ||
if _, exists := user.Permissions[acl.TargetUserID.String()]; !exists { | ||
user.Permissions[acl.TargetUserID.String()] = make(map[string]bool) | ||
} | ||
user.Permissions[acl.TargetUserID.String()][string(acl.Permission)] = true | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally this would be done with GORM Associations -- so we could use a single query.
https://gorm.io/docs/create.html#Create-With-Associations
https://gorm.io/docs/query.html#Joins-Preloading
if result.Error != nil { | ||
return result.Error | ||
} | ||
// Update User Permissions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ideally this would all be handed by the GORM Association logic & hooks
Picture string `json:"picture"` | ||
Email string `json:"email"` | ||
Role pkg.UserRole `json:"role"` | ||
Permissions map[string]map[string]bool `json:"permissions" gorm:"-:all"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use GORM references for this - https://gorm.io/docs/has_many.html#Override-References
Part of #57
This adds the ability for an admin user to set permissions for each user. This does not allow these permissions to be used, that will be in the next PR.