2017-06-29 14:57:59 -04:00
|
|
|
require_dependency 'declarative_policy'
|
2016-08-16 15:55:44 -04:00
|
|
|
|
2017-04-06 17:06:42 -04:00
|
|
|
class BasePolicy < DeclarativePolicy::Base
|
2017-06-30 09:29:34 -04:00
|
|
|
include Gitlab::CurrentSettings
|
2016-08-16 15:05:44 -04:00
|
|
|
|
2017-04-06 17:06:42 -04:00
|
|
|
desc "User is an instance admin"
|
|
|
|
with_options scope: :user, score: 0
|
|
|
|
condition(:admin) { @user&.admin? }
|
2016-08-11 18:12:52 -04:00
|
|
|
|
2017-04-06 17:06:42 -04:00
|
|
|
with_options scope: :user, score: 0
|
|
|
|
condition(:external_user) { @user.nil? || @user.external? }
|
2016-08-12 14:36:16 -04:00
|
|
|
|
2017-04-06 17:06:42 -04:00
|
|
|
with_options scope: :user, score: 0
|
|
|
|
condition(:can_create_group) { @user&.can_create_group }
|
2017-06-29 03:43:41 -04:00
|
|
|
|
2017-06-30 09:29:34 -04:00
|
|
|
desc "The application is restricted from public visibility"
|
|
|
|
condition(:restricted_public_level, scope: :global) do
|
2017-06-29 03:43:41 -04:00
|
|
|
current_application_settings.restricted_visibility_levels.include?(Gitlab::VisibilityLevel::PUBLIC)
|
|
|
|
end
|
2016-08-11 18:12:52 -04:00
|
|
|
end
|