diff options
author | Phil Hughes <me@iamphill.com> | 2017-09-29 12:14:39 +0100 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2017-09-29 12:14:39 +0100 |
commit | 93aa6d04c2e81193d7833890d2281fc1df7d7129 (patch) | |
tree | 166a52d9ffdf1bbd3ef073b88626707e9a1acc16 /app/policies | |
parent | 8585ae61e730a48fc0688417b24279c48b59dada (diff) | |
download | gitlab-ce-93aa6d04c2e81193d7833890d2281fc1df7d7129.tar.gz |
moved fork checks into policiesfork-btn-enabled-user-groups
Diffstat (limited to 'app/policies')
-rw-r--r-- | app/policies/global_policy.rb | 6 | ||||
-rw-r--r-- | app/policies/namespace_policy.rb | 4 |
2 files changed, 10 insertions, 0 deletions
diff --git a/app/policies/global_policy.rb b/app/policies/global_policy.rb index 8f7c01bb71f..64e550d19d0 100644 --- a/app/policies/global_policy.rb +++ b/app/policies/global_policy.rb @@ -11,6 +11,8 @@ class GlobalPolicy < BasePolicy with_options scope: :user, score: 0 condition(:access_locked) { @user.access_locked? } + condition(:can_create_fork, scope: :user) { @user.manageable_namespaces.any? { |namespace| @user.can?(:create_projects, namespace) } } + rule { anonymous }.policy do prevent :log_in prevent :access_api @@ -40,6 +42,10 @@ class GlobalPolicy < BasePolicy enable :create_group end + rule { can_create_fork }.policy do + enable :create_fork + end + rule { access_locked }.policy do prevent :log_in end diff --git a/app/policies/namespace_policy.rb b/app/policies/namespace_policy.rb index 85b67f0a237..92213f0155e 100644 --- a/app/policies/namespace_policy.rb +++ b/app/policies/namespace_policy.rb @@ -1,10 +1,14 @@ class NamespacePolicy < BasePolicy rule { anonymous }.prevent_all + condition(:personal_project, scope: :subject) { @subject.kind == 'user' } + condition(:can_create_personal_project, scope: :user) { @user.can_create_project? } condition(:owner) { @subject.owner == @user } rule { owner | admin }.policy do enable :create_projects enable :admin_namespace end + + rule { personal_project & ~can_create_personal_project }.prevent :create_projects end |