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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
fa01c373
Commit
fa01c373
authored
Apr 25, 2017
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensures that OAuth/LDAP/SAML users don't need to be confirmed
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
3c6fad64
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
4 deletions
+45
-4
app/services/users/build_service.rb
app/services/users/build_service.rb
+4
-4
spec/lib/gitlab/ldap/user_spec.rb
spec/lib/gitlab/ldap/user_spec.rb
+13
-0
spec/lib/gitlab/o_auth/user_spec.rb
spec/lib/gitlab/o_auth/user_spec.rb
+15
-0
spec/lib/gitlab/saml/user_spec.rb
spec/lib/gitlab/saml/user_spec.rb
+13
-0
No files found.
app/services/users/build_service.rb
View file @
fa01c373
...
@@ -9,12 +9,11 @@ module Users
...
@@ -9,12 +9,11 @@ module Users
def
execute
(
skip_authorization:
false
)
def
execute
(
skip_authorization:
false
)
raise
Gitlab
::
Access
::
AccessDeniedError
unless
skip_authorization
||
can_create_user?
raise
Gitlab
::
Access
::
AccessDeniedError
unless
skip_authorization
||
can_create_user?
user
=
User
.
new
(
build_user_params
)
user
=
User
.
new
(
build_user_params
(
skip_authorization:
skip_authorization
)
)
if
current_user
&
.
admin?
if
current_user
&
.
admin?
if
params
[
:reset_password
]
if
params
[
:reset_password
]
user
.
generate_reset_token
user
.
generate_reset_token
params
[
:force_random_password
]
=
true
end
end
if
params
[
:force_random_password
]
if
params
[
:force_random_password
]
...
@@ -81,7 +80,7 @@ module Users
...
@@ -81,7 +80,7 @@ module Users
]
]
end
end
def
build_user_params
def
build_user_params
(
skip_authorization
:)
if
current_user
&
.
admin?
if
current_user
&
.
admin?
user_params
=
params
.
slice
(
*
admin_create_params
)
user_params
=
params
.
slice
(
*
admin_create_params
)
user_params
[
:created_by_id
]
=
current_user
&
.
id
user_params
[
:created_by_id
]
=
current_user
&
.
id
...
@@ -91,7 +90,8 @@ module Users
...
@@ -91,7 +90,8 @@ module Users
end
end
else
else
user_params
=
params
.
slice
(
*
signup_params
)
user_params
=
params
.
slice
(
*
signup_params
)
user_params
[
:skip_confirmation
]
=
!
current_application_settings
.
send_user_confirmation_email
user_params
[
:skip_confirmation
]
=
params
[
:skip_confirmation
]
if
skip_authorization
user_params
[
:skip_confirmation
]
||=
!
current_application_settings
.
send_user_confirmation_email
end
end
user_params
user_params
...
...
spec/lib/gitlab/ldap/user_spec.rb
View file @
fa01c373
...
@@ -120,6 +120,19 @@ describe Gitlab::LDAP::User, lib: true do
...
@@ -120,6 +120,19 @@ describe Gitlab::LDAP::User, lib: true do
expect
(
gl_user
).
to
be_persisted
expect
(
gl_user
).
to
be_persisted
end
end
end
end
context
'when user confirmation email is enabled'
do
before
do
stub_application_setting
send_user_confirmation_email:
true
end
it
'creates and confirms the user anyway'
do
ldap_user
.
save
expect
(
gl_user
).
to
be_persisted
expect
(
gl_user
).
to
be_confirmed
end
end
end
end
describe
'updating email'
do
describe
'updating email'
do
...
...
spec/lib/gitlab/o_auth/user_spec.rb
View file @
fa01c373
...
@@ -54,6 +54,21 @@ describe Gitlab::OAuth::User, lib: true do
...
@@ -54,6 +54,21 @@ describe Gitlab::OAuth::User, lib: true do
end
end
end
end
context
'when user confirmation email is enabled'
do
before
do
stub_application_setting
send_user_confirmation_email:
true
end
it
'creates and confirms the user anyway'
do
stub_omniauth_config
(
allow_single_sign_on:
[
'twitter'
])
oauth_user
.
save
expect
(
gl_user
).
to
be_persisted
expect
(
gl_user
).
to
be_confirmed
end
end
it
'marks user as having password_automatically_set'
do
it
'marks user as having password_automatically_set'
do
stub_omniauth_config
(
allow_single_sign_on:
[
'twitter'
],
external_providers:
[
'twitter'
])
stub_omniauth_config
(
allow_single_sign_on:
[
'twitter'
],
external_providers:
[
'twitter'
])
...
...
spec/lib/gitlab/saml/user_spec.rb
View file @
fa01c373
...
@@ -223,6 +223,19 @@ describe Gitlab::Saml::User, lib: true do
...
@@ -223,6 +223,19 @@ describe Gitlab::Saml::User, lib: true do
expect
(
gl_user
).
to
be_persisted
expect
(
gl_user
).
to
be_persisted
end
end
end
end
context
'when user confirmation email is enabled'
do
before
do
stub_application_setting
send_user_confirmation_email:
true
end
it
'creates and confirms the user anyway'
do
saml_user
.
save
expect
(
gl_user
).
to
be_persisted
expect
(
gl_user
).
to
be_confirmed
end
end
end
end
describe
'blocking'
do
describe
'blocking'
do
...
...
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