mirror of
https://github.com/lunaisnotaboy/mastodon.git
synced 2024-11-05 14:36:04 +00:00
51e154f5e8
Fix #6856 Fix #6951
54 lines
738 B
Ruby
54 lines
738 B
Ruby
# frozen_string_literal: true
|
|
|
|
class UserPolicy < ApplicationPolicy
|
|
def reset_password?
|
|
staff? && !record.staff?
|
|
end
|
|
|
|
def change_email?
|
|
staff? && !record.staff?
|
|
end
|
|
|
|
def disable_2fa?
|
|
admin? && !record.staff?
|
|
end
|
|
|
|
def confirm?
|
|
staff? && !record.confirmed?
|
|
end
|
|
|
|
def enable?
|
|
staff?
|
|
end
|
|
|
|
def approve?
|
|
staff? && !record.approved?
|
|
end
|
|
|
|
def reject?
|
|
staff? && !record.approved?
|
|
end
|
|
|
|
def disable?
|
|
staff? && !record.admin?
|
|
end
|
|
|
|
def promote?
|
|
admin? && promoteable?
|
|
end
|
|
|
|
def demote?
|
|
admin? && !record.admin? && demoteable?
|
|
end
|
|
|
|
private
|
|
|
|
def promoteable?
|
|
record.approved? && (!record.staff? || !record.admin?)
|
|
end
|
|
|
|
def demoteable?
|
|
record.staff?
|
|
end
|
|
end
|