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
iv
gitlab-ce
Commits
f40e87a0
Commit
f40e87a0
authored
Jun 24, 2014
by
Marin Jankovski
Committed by
Dmitriy Zaporozhets
Jun 24, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Return better error when account exists when attempting oauth account create.
parent
2d9667df
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
5 deletions
+16
-5
app/controllers/omniauth_callbacks_controller.rb
app/controllers/omniauth_callbacks_controller.rb
+9
-4
lib/gitlab/oauth/user.rb
lib/gitlab/oauth/user.rb
+7
-1
No files found.
app/controllers/omniauth_callbacks_controller.rb
View file @
f40e87a0
...
@@ -45,14 +45,19 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
...
@@ -45,14 +45,19 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
# Create user if does not exist
# Create user if does not exist
# and allow_single_sign_on is true
# and allow_single_sign_on is true
if
Gitlab
.
config
.
omniauth
[
'allow_single_sign_on'
]
if
Gitlab
.
config
.
omniauth
[
'allow_single_sign_on'
]
&&
!
@user
@user
||
=
Gitlab
::
OAuth
::
User
.
create
(
oauth
)
@user
,
errors
=
Gitlab
::
OAuth
::
User
.
create
(
oauth
)
end
end
if
@user
if
@user
&&
!
errors
sign_in_and_redirect
(
@user
)
sign_in_and_redirect
(
@user
)
else
else
flash
[
:notice
]
=
"There's no such user!"
if
errors
error_message
=
errors
.
map
{
|
attribute
,
message
|
"
#{
attribute
}
#{
message
}
"
}.
join
(
", "
)
flash
[
:notice
]
=
"There was a problem creating your account.
#{
error_message
}
"
else
flash
[
:notice
]
=
"There's no such user!"
end
redirect_to
new_user_session_path
redirect_to
new_user_session_path
end
end
end
end
...
...
lib/gitlab/oauth/user.rb
View file @
f40e87a0
...
@@ -44,7 +44,13 @@ module Gitlab
...
@@ -44,7 +44,13 @@ module Gitlab
user
.
username
=
email_username
.
gsub
(
"'"
,
""
)
user
.
username
=
email_username
.
gsub
(
"'"
,
""
)
end
end
user
.
save!
begin
user
.
save!
rescue
ActiveRecord
::
RecordInvalid
=>
e
log
.
info
"(OAuth) Email
#{
e
.
record
.
errors
[
:email
]
}
. Username
#{
e
.
record
.
errors
[
:username
]
}
"
return
nil
,
e
.
record
.
errors
end
log
.
info
"(OAuth) Creating user
#{
email
}
from login with extern_uid =>
#{
uid
}
"
log
.
info
"(OAuth) Creating user
#{
email
}
from login with extern_uid =>
#{
uid
}
"
if
Gitlab
.
config
.
omniauth
[
'block_auto_created_users'
]
&&
!
ldap?
if
Gitlab
.
config
.
omniauth
[
'block_auto_created_users'
]
&&
!
ldap?
...
...
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