Add emails index page at https://danbooru.donmai.us/emails. Mods can use this page to view and search emails belonging to users below mod level.
28 lines
599 B
Ruby
28 lines
599 B
Ruby
class EmailAddressPolicy < ApplicationPolicy
|
|
def index?
|
|
user.is_moderator?
|
|
end
|
|
|
|
def show?
|
|
record.user_id == user.id || (user.is_moderator? && record.user.level < user.level)
|
|
end
|
|
|
|
def update?
|
|
# XXX here record is a user, not the email address.
|
|
record.id == user.id
|
|
end
|
|
|
|
def verify?
|
|
if request.params[:email_verification_key].present?
|
|
record.valid_key?(request.params[:email_verification_key])
|
|
else
|
|
record.user_id == user.id
|
|
end
|
|
end
|
|
|
|
def send_confirmation?
|
|
# XXX record is a user, not the email address.
|
|
record.id == user.id
|
|
end
|
|
end
|