summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-04-07 16:36:33 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-04-07 16:36:33 +0300
commit5436d6afd614f929a67c8b0257fa1644823d55b3 (patch)
treef6bd3ee76876f25ca35eb5aaf5523a28b2cb6c41 /lib
parent021faad3fe1026ec0c1ea6debbd4eb28e74ffcb8 (diff)
downloadgitlab-ce-5436d6afd614f929a67c8b0257fa1644823d55b3.tar.gz
Make oauth works for google oauth too
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/oauth/user.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/gitlab/oauth/user.rb b/lib/gitlab/oauth/user.rb
index 65d692034ba..94a76f11685 100644
--- a/lib/gitlab/oauth/user.rb
+++ b/lib/gitlab/oauth/user.rb
@@ -30,12 +30,18 @@ module Gitlab
user = model.build_user(opts, as: :admin)
user.skip_confirmation!
+ # Services like twitter and github does not return email via oauth
+ # In this case we generate temporary email and force user to fill it later
if user.email.blank?
user.generate_tmp_oauth_email
+ user.save!(validate: false)
+ else
+ # Google oauth returns email but dont return nickname
+ # So we use part of email as username for new user
+ user.username = email.match(/^[^@]*/)[0]
+ user.save
end
- user.save!(validate: false)
-
log.info "(OAuth) Creating user #{email} from login with extern_uid => #{uid}"
if Gitlab.config.omniauth['block_auto_created_users'] && !ldap?