mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-20 03:25:17 +01:00
Extract private method in user role policy
This commit is contained in:
parent
63b8d7dd23
commit
5c30c34a4c
@ -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