Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
634a1527
Commit
634a1527
authored
Nov 06, 2017
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure group and project creation is blocked for new users that are external by default
parent
97b80fef
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
5 deletions
+14
-5
app/models/user.rb
app/models/user.rb
+4
-3
changelogs/unreleased/dm-block-group-and-project-creation-when-external-by-default.yml
...k-group-and-project-creation-when-external-by-default.yml
+6
-0
spec/models/user_spec.rb
spec/models/user_spec.rb
+4
-2
No files found.
app/models/user.rb
View file @
634a1527
...
...
@@ -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
...
...
changelogs/unreleased/dm-block-group-and-project-creation-when-external-by-default.yml
0 → 100644
View file @
634a1527
---
title
:
Make sure group and project creation is blocked for new users that are external
by default
merge_request
:
author
:
type
:
fixed
spec/models/user_spec.rb
View file @
634a1527
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment