debian-mirror-gitlab/app/policies/user_policy.rb

14 lines
447 B
Ruby
Raw Normal View History

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
2017-09-10 17:25:29 +05:30
rule { user_is_self | admin }.enable :destroy_user
rule { subject_ghost }.prevent :destroy_user
2016-09-29 09:46:39 +05:30
end