BigW Consortium Gitlab

Commit 634a1527 by Douwe Maan

Make sure group and project creation is blocked for new users that are external by default

parent 97b80fef
......@@ -164,7 +164,7 @@ class User < ActiveRecord::Base
before_validation :set_notification_email, if: :email_changed?
before_validation :set_public_email, if: :public_email_changed?
before_save :ensure_incoming_email_token
before_save :ensure_user_rights_and_limits, if: :external_changed?
before_save :ensure_user_rights_and_limits, if: ->(user) { user.new_record? || user.external_changed? }
before_save :skip_reconfirmation!, if: ->(user) { user.email_changed? && user.read_only_attribute?(:email) }
before_save :check_for_verified_email, if: ->(user) { user.email_changed? && !user.new_record? }
after_save :ensure_namespace_correct
......@@ -1139,8 +1139,9 @@ class User < ActiveRecord::Base
self.can_create_group = false
self.projects_limit = 0
else
self.can_create_group = gitlab_config.default_can_create_group
self.projects_limit = current_application_settings.default_projects_limit
# Only revert these back to the default if they weren't specifically changed in this update.
self.can_create_group = gitlab_config.default_can_create_group unless can_create_group_changed?
self.projects_limit = current_application_settings.default_projects_limit unless projects_limit_changed?
end
end
......
---
title: Make sure group and project creation is blocked for new users that are external
by default
merge_request:
author:
type: fixed
......@@ -788,14 +788,16 @@ describe User do
end
it "creates external user by default" do
user = build(:user)
user = create(:user)
expect(user.external).to be_truthy
expect(user.can_create_group).to be_falsey
expect(user.projects_limit).to be 0
end
describe 'with default overrides' do
it "creates a non-external user" do
user = build(:user, external: false)
user = create(:user, external: false)
expect(user.external).to be_falsey
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment