2016-09-29 09:46:39 +05:30
|
|
|
class UserPolicy < BasePolicy
|
2017-09-10 17:25:29 +05:30
|
|
|
desc "The current user is the user in question"
|
|
|
|
condition(:user_is_self, score: 0) { @subject == @user }
|
2016-09-29 09:46:39 +05:30
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
desc "This is the ghost user"
|
|
|
|
condition(:subject_ghost, scope: :subject, score: 0) { @subject.ghost? }
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
rule { ~restricted_public_level }.enable :read_user
|
|
|
|
rule { ~anonymous }.enable :read_user
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
rule { ~subject_ghost & (user_is_self | admin) }.policy do
|
|
|
|
enable :destroy_user
|
|
|
|
enable :update_user
|
|
|
|
end
|
2016-09-29 09:46:39 +05:30
|
|
|
end
|