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
dd09a19a
Commit
dd09a19a
authored
Apr 23, 2018
by
James Edwards-Jones
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Auth::User classes refactor adds should_save?
parent
795cd7f9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
18 deletions
+10
-18
lib/gitlab/auth/ldap/user.rb
lib/gitlab/auth/ldap/user.rb
+2
-6
lib/gitlab/auth/o_auth/user.rb
lib/gitlab/auth/o_auth/user.rb
+2
-2
lib/gitlab/auth/saml/user.rb
lib/gitlab/auth/saml/user.rb
+2
-6
spec/lib/gitlab/auth/ldap/user_spec.rb
spec/lib/gitlab/auth/ldap/user_spec.rb
+4
-4
No files found.
lib/gitlab/auth/ldap/user.rb
View file @
dd09a19a
...
...
@@ -31,15 +31,11 @@ module Gitlab
self
.
class
.
find_by_uid_and_provider
(
auth_hash
.
uid
,
auth_hash
.
provider
)
end
def
changed?
override
:should_save?
def
should_save?
gl_user
.
changed?
||
gl_user
.
identities
.
any?
(
&
:changed?
)
end
override
:omniauth_should_save?
def
omniauth_should_save?
changed?
&&
super
end
def
block_after_signup?
ldap_config
.
block_auto_created_users
end
...
...
lib/gitlab/auth/o_auth/user.rb
View file @
dd09a19a
...
...
@@ -69,14 +69,14 @@ module Gitlab
end
def
find_and_update!
save
if
omniauth_
should_save?
save
if
should_save?
gl_user
end
protected
def
omniauth_
should_save?
def
should_save?
true
end
...
...
lib/gitlab/auth/saml/user.rb
View file @
dd09a19a
...
...
@@ -29,17 +29,13 @@ module Gitlab
user
end
def
changed?
override
:should_save?
def
should_save?
return
true
unless
gl_user
gl_user
.
changed?
||
gl_user
.
identities
.
any?
(
&
:changed?
)
end
override
:omniauth_should_save?
def
omniauth_should_save?
changed?
&&
super
end
protected
def
saml_config
...
...
spec/lib/gitlab/auth/ldap/user_spec.rb
View file @
dd09a19a
...
...
@@ -25,20 +25,20 @@ describe Gitlab::Auth::LDAP::User do
OmniAuth
::
AuthHash
.
new
(
uid:
'uid=John Smith,ou=People,dc=example,dc=com'
,
provider:
'ldapmain'
,
info:
info_upper_case
)
end
describe
'#
changed
?'
do
describe
'#
should_save
?'
do
it
"marks existing ldap user as changed"
do
create
(
:omniauth_user
,
extern_uid:
'uid=John Smith,ou=People,dc=example,dc=com'
,
provider:
'ldapmain'
)
expect
(
ldap_user
.
changed
?
).
to
be_truthy
expect
(
ldap_user
.
should_save
?
).
to
be_truthy
end
it
"marks existing non-ldap user if the email matches as changed"
do
create
(
:user
,
email:
'john@example.com'
)
expect
(
ldap_user
.
changed
?
).
to
be_truthy
expect
(
ldap_user
.
should_save
?
).
to
be_truthy
end
it
"does not mark existing ldap user as changed"
do
create
(
:omniauth_user
,
email:
'john@example.com'
,
extern_uid:
'uid=john smith,ou=people,dc=example,dc=com'
,
provider:
'ldapmain'
)
expect
(
ldap_user
.
changed
?
).
to
be_falsey
expect
(
ldap_user
.
should_save
?
).
to
be_falsey
end
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