* Let Mods and Admins see the email addresses of users below their level. * Let users see their own email address on their profile. * Let users verify or edit their email address from their profile. This is to make catching sockpuppets easier, and to make it easier for users to fix their email.
24 lines
556 B
Ruby
24 lines
556 B
Ruby
class EmailAddressPolicy < ApplicationPolicy
|
|
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
|