mirror of
https://github.com/mastodon/mastodon.git
synced 2025-01-08 19:35:11 +01:00
Add self_editing?
method to user role policy (#33476)
This commit is contained in:
parent
dd937e115a
commit
edf62d4fe3
@ -10,10 +10,16 @@ class UserRolePolicy < ApplicationPolicy
|
||||
end
|
||||
|
||||
def update?
|
||||
role.can?(:manage_roles) && (role.overrides?(record) || role.id == record.id)
|
||||
role.can?(:manage_roles) && (role.overrides?(record) || self_editing?)
|
||||
end
|
||||
|
||||
def destroy?
|
||||
!record.everyone? && role.can?(:manage_roles) && role.overrides?(record) && role.id != record.id
|
||||
!record.everyone? && role.can?(:manage_roles) && role.overrides?(record) && !self_editing?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def self_editing?
|
||||
role.id == record.id
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user