Commit 5436d6afd614f929a67c8b0257fa1644823d55b3

Authored by Dmitriy Zaporozhets
1 parent 021faad3

Make oauth works for google oauth too

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing 2 changed files with 9 additions and 2 deletions   Show diff stats
CHANGELOG
... ... @@ -8,6 +8,7 @@ v 6.8.0
8 8 - Create branches via API (sponsored by O'Reilly Media)
9 9 - Changed permission of gitlab-satellites directory not to be world accessible
10 10 - Protected branch does not allow force push
  11 + - Allow oauth signup without email for twitter and github
11 12  
12 13 v 6.7.3
13 14 - Fix the merge notification email not being sent (Pierre de La Morinerie)
... ...
lib/gitlab/oauth/user.rb
... ... @@ -30,12 +30,18 @@ module Gitlab
30 30 user = model.build_user(opts, as: :admin)
31 31 user.skip_confirmation!
32 32  
  33 + # Services like twitter and github does not return email via oauth
  34 + # In this case we generate temporary email and force user to fill it later
33 35 if user.email.blank?
34 36 user.generate_tmp_oauth_email
  37 + user.save!(validate: false)
  38 + else
  39 + # Google oauth returns email but dont return nickname
  40 + # So we use part of email as username for new user
  41 + user.username = email.match(/^[^@]*/)[0]
  42 + user.save
35 43 end
36 44  
37   - user.save!(validate: false)
38   -
39 45 log.info "(OAuth) Creating user #{email} from login with extern_uid => #{uid}"
40 46  
41 47 if Gitlab.config.omniauth['block_auto_created_users'] && !ldap?
... ...