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

69 lines
1.6 KiB
Ruby
Raw Normal View History

2016-09-29 09:46:39 +05:30
class GlobalPolicy < BasePolicy
2017-09-10 17:25:29 +05:30
desc "User is blocked"
with_options scope: :user, score: 0
2018-10-15 14:42:47 +05:30
condition(:blocked) { @user&.blocked? }
2017-09-10 17:25:29 +05:30
desc "User is an internal user"
with_options scope: :user, score: 0
2018-10-15 14:42:47 +05:30
condition(:internal) { @user&.internal? }
2017-09-10 17:25:29 +05:30
desc "User's access has been locked"
with_options scope: :user, score: 0
2018-10-15 14:42:47 +05:30
condition(:access_locked) { @user&.access_locked? }
2017-09-10 17:25:29 +05:30
2018-10-15 14:42:47 +05:30
condition(:can_create_fork, scope: :user) { @user && @user.manageable_namespaces.any? { |namespace| @user.can?(:create_projects, namespace) } }
condition(:required_terms_not_accepted, scope: :user, score: 0) do
@user&.required_terms_not_accepted?
end
2018-03-17 18:26:18 +05:30
2017-09-10 17:25:29 +05:30
rule { anonymous }.policy do
prevent :log_in
prevent :receive_notifications
prevent :use_quick_actions
prevent :create_group
end
rule { default }.policy do
enable :log_in
enable :access_api
enable :access_git
enable :receive_notifications
enable :use_quick_actions
end
rule { blocked | internal }.policy do
prevent :log_in
prevent :access_api
prevent :access_git
prevent :receive_notifications
prevent :use_quick_actions
end
2018-10-15 14:42:47 +05:30
rule { required_terms_not_accepted }.policy do
prevent :access_api
prevent :access_git
end
2017-09-10 17:25:29 +05:30
rule { can_create_group }.policy do
enable :create_group
end
2018-03-17 18:26:18 +05:30
rule { can_create_fork }.policy do
enable :create_fork
end
2017-09-10 17:25:29 +05:30
rule { access_locked }.policy do
prevent :log_in
end
rule { ~(anonymous & restricted_public_level) }.policy do
enable :read_users_list
2016-09-29 09:46:39 +05:30
end
2018-03-17 18:26:18 +05:30
rule { admin }.policy do
enable :read_custom_attribute
enable :update_custom_attribute
end
2016-09-29 09:46:39 +05:30
end