mirror of
https://github.com/mastodon/mastodon
synced 2025-01-10 20:03:22 +09: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
|
end
|
||||||
|
|
||||||
def update?
|
def update?
|
||||||
role.can?(:manage_roles) && (role.overrides?(record) || role.id == record.id)
|
role.can?(:manage_roles) && (role.overrides?(record) || self_editing?)
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy?
|
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
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user