mirror of
https://github.com/lunaisnotaboy/mastodon.git
synced 2024-12-30 17:16:41 +00:00
219a4423d8
* Admin: Show unconfirmed email address on account page * Admin: Allow staff to change user email addresses * ActionLog: On change_email, log current email address and new unconfirmed email address
46 lines
609 B
Ruby
46 lines
609 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?
|
|
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
|