pundit: convert user name change requests to pundit.
Fix discrepancy between index action and show action. The index action allowed members to see name changes for undeleted users, but the show action didn't.
This commit is contained in:
13
app/policies/user_name_change_request_policy.rb
Normal file
13
app/policies/user_name_change_request_policy.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
class UserNameChangeRequestPolicy < ApplicationPolicy
|
||||
def index?
|
||||
user.is_member?
|
||||
end
|
||||
|
||||
def show?
|
||||
user.is_admin? || (user.is_member? && !record.user.is_deleted?) || (record.user == user)
|
||||
end
|
||||
|
||||
def permitted_attributes
|
||||
[:desired_name, :desired_name_confirmation]
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user