You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
776 B
37 lines
776 B
2 years ago
|
class UserPolicy
|
||
|
attr_reader :current_user, :user
|
||
|
|
||
|
def initialize(current_user, user)
|
||
|
@current_user = current_user
|
||
|
@user = user
|
||
|
end
|
||
|
|
||
|
def edit_password?
|
||
|
@current_user == @user
|
||
|
end
|
||
|
|
||
|
def edit_roles?
|
||
|
(@current_user.data_coordinator? || @current_user.support?) && @user.active?
|
||
|
end
|
||
|
|
||
|
%w[
|
||
|
edit_roles?
|
||
|
edit_dpo?
|
||
|
edit_key_contact?
|
||
|
].each do |method_name|
|
||
|
define_method method_name do
|
||
|
(@current_user.data_coordinator? || @current_user.support?) && @user.active?
|
||
|
end
|
||
|
end
|
||
|
|
||
|
%w[
|
||
|
edit_emails?
|
||
|
edit_telephone_numbers?
|
||
|
edit_names?
|
||
|
].each do |method_name|
|
||
|
define_method method_name do
|
||
|
(@current_user == @user || @current_user.data_coordinator? || @current_user.support?) && @user.active?
|
||
|
end
|
||
|
end
|
||
|
end
|