mirror of
https://github.com/whippyshou/mastodon
synced 2024-12-02 08:48:33 +09:00
42 lines
553 B
Ruby
42 lines
553 B
Ruby
|
# frozen_string_literal: true
|
||
|
|
||
|
class UserPolicy < ApplicationPolicy
|
||
|
def reset_password?
|
||
|
staff? && !record.staff?
|
||
|
end
|
||
|
|
||
|
def disable_2fa?
|
||
|
admin? && !record.staff?
|
||
|
end
|
||
|
|
||
|
def confirm?
|
||
|
staff? && !record.confirmed?
|
||
|
end
|
||
|
|
||
|
def enable?
|
||
|
admin?
|
||
|
end
|
||
|
|
||
|
def disable?
|
||
|
admin? && !record.admin?
|
||
|
end
|
||
|
|
||
|
def promote?
|
||
|
admin? && promoteable?
|
||
|
end
|
||
|
|
||
|
def demote?
|
||
|
admin? && !record.admin? && demoteable?
|
||
|
end
|
||
|
|
||
|
private
|
||
|
|
||
|
def promoteable?
|
||
|
!record.staff? || !record.admin?
|
||
|
end
|
||
|
|
||
|
def demoteable?
|
||
|
record.staff?
|
||
|
end
|
||
|
end
|