diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-04-07 17:15:31 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-04-07 17:15:31 +0300 |
commit | 650d0bc695eb0f874561b8d4ed3fc86510573fba (patch) | |
tree | 70da3eb09b3d8f0e34997158272cf36c8e7fe0fa /lib | |
parent | 5d6e9ea8efa07d5342857de0772b59a4c5092f60 (diff) | |
parent | e6f58cb87da914f2a424df66b680e19e49dcd2e6 (diff) | |
download | gitlab-ce-650d0bc695eb0f874561b8d4ed3fc86510573fba.tar.gz |
Merge branch 'improve-oauth'
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Conflicts:
CHANGELOG
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/oauth/user.rb | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/gitlab/oauth/user.rb b/lib/gitlab/oauth/user.rb index 529753c4019..1bac93378ef 100644 --- a/lib/gitlab/oauth/user.rb +++ b/lib/gitlab/oauth/user.rb @@ -29,6 +29,17 @@ 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 + 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] + end + user.save! log.info "(OAuth) Creating user #{email} from login with extern_uid => #{uid}" @@ -58,7 +69,7 @@ module Gitlab end def username - email.match(/^[^@]*/)[0] + auth.info.nickname.to_s.force_encoding("utf-8") end def provider |