2016-08-18 12:59:17 -04:00
|
|
|
class UserPolicy < BasePolicy
|
2017-04-06 17:06:42 -04:00
|
|
|
desc "The current user is the user in question"
|
|
|
|
condition(:user_is_self, score: 0) { @subject == @user }
|
2017-02-17 09:58:12 -05:00
|
|
|
|
2017-04-06 17:06:42 -04:00
|
|
|
desc "This is the ghost user"
|
|
|
|
condition(:subject_ghost, scope: :subject, score: 0) { @subject.ghost? }
|
2017-02-17 09:58:12 -05:00
|
|
|
|
2017-04-06 17:06:42 -04:00
|
|
|
rule { ~restricted_public_level }.enable :read_user
|
|
|
|
rule { ~anonymous }.enable :read_user
|
|
|
|
|
|
|
|
rule { user_is_self | admin }.enable :destroy_user
|
|
|
|
rule { subject_ghost }.prevent :destroy_user
|
2016-08-18 12:59:17 -04:00
|
|
|
end
|