refac: debt on role backend
This commit is contained in:
1 parent
de142f6c5f
commit
a043f7f41a
130 files changed
+3591
-512
No files matched your search
@@ -93,10 +93,14 @@ func (u *UpdateAuthorUseCase) prepare(before author.Author, caller AuthorCaller,
|
||||
}
|
||||
|
||||
func authorizeEdit(before author.Author, caller AuthorCaller, patch author.Patch) error {
|
||||
if caller.Grants.HoldsAll(role.KeyAuthorsEdit) {
|
||||
return nil
|
||||
var linkedID uint32
|
||||
if before.UserID != nil {
|
||||
linkedID = *before.UserID
|
||||
}
|
||||
if before.UserID == nil || *before.UserID != caller.UserID || patch.UserID.Set {
|
||||
if !caller.Grants.Permits(role.KeyAuthorsEdit, "", caller.UserID, linkedID) {
|
||||
return author.ErrAuthorRights
|
||||
}
|
||||
if patch.UserID.Set && !caller.Grants.HoldsAll(role.KeyAuthorsEdit) {
|
||||
return author.ErrAuthorRights
|
||||
}
|
||||
return nil
|
||||
|
||||
Reference in new issue
Block a user