debian-mirror-gitlab/app/policies/namespaces/user_namespace_policy.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

27 lines
782 B
Ruby
Raw Normal View History

2021-11-18 22:05:49 +05:30
# frozen_string_literal: true
module Namespaces
2022-01-26 12:08:38 +05:30
class UserNamespacePolicy < ::NamespacePolicy
2021-11-18 22:05:49 +05:30
rule { anonymous }.prevent_all
condition(:can_create_personal_project, scope: :user) { @user.can_create_project? }
condition(:owner) { @subject.owner == @user }
rule { owner | admin }.policy do
enable :owner_access
enable :create_projects
enable :admin_namespace
enable :read_namespace
enable :read_statistics
enable :create_jira_connect_subscription
2022-07-16 23:28:13 +05:30
enable :admin_package
2021-11-18 22:05:49 +05:30
end
2022-01-26 12:08:38 +05:30
rule { ~can_create_personal_project }.prevent :create_projects
2021-11-18 22:05:49 +05:30
rule { (owner | admin) & can?(:create_projects) }.enable :transfer_projects
end
end
Namespaces::UserNamespacePolicy.prepend_mod_with('Namespaces::UserNamespacePolicy')