Commit e6f58cb87da914f2a424df66b680e19e49dcd2e6
1 parent
5436d6af
Exists in
spb-stable
and in
3 other branches
Avoid false validation when create user
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing
2 changed files
with
2 additions
and
3 deletions
Show diff stats
app/models/user.rb
| @@ -468,6 +468,6 @@ class User < ActiveRecord::Base | @@ -468,6 +468,6 @@ class User < ActiveRecord::Base | ||
| 468 | end | 468 | end |
| 469 | 469 | ||
| 470 | def generate_tmp_oauth_email | 470 | def generate_tmp_oauth_email |
| 471 | - self.email = "temp-email-for-oauth-#{username}" | 471 | + self.email = "temp-email-for-oauth-#{username}@gitlab.localhost" |
| 472 | end | 472 | end |
| 473 | end | 473 | end |
lib/gitlab/oauth/user.rb
| @@ -34,14 +34,13 @@ module Gitlab | @@ -34,14 +34,13 @@ module Gitlab | ||
| 34 | # In this case we generate temporary email and force user to fill it later | 34 | # In this case we generate temporary email and force user to fill it later |
| 35 | if user.email.blank? | 35 | if user.email.blank? |
| 36 | user.generate_tmp_oauth_email | 36 | user.generate_tmp_oauth_email |
| 37 | - user.save!(validate: false) | ||
| 38 | else | 37 | else |
| 39 | # Google oauth returns email but dont return nickname | 38 | # Google oauth returns email but dont return nickname |
| 40 | # So we use part of email as username for new user | 39 | # So we use part of email as username for new user |
| 41 | user.username = email.match(/^[^@]*/)[0] | 40 | user.username = email.match(/^[^@]*/)[0] |
| 42 | - user.save | ||
| 43 | end | 41 | end |
| 44 | 42 | ||
| 43 | + user.save! | ||
| 45 | log.info "(OAuth) Creating user #{email} from login with extern_uid => #{uid}" | 44 | log.info "(OAuth) Creating user #{email} from login with extern_uid => #{uid}" |
| 46 | 45 | ||
| 47 | if Gitlab.config.omniauth['block_auto_created_users'] && !ldap? | 46 | if Gitlab.config.omniauth['block_auto_created_users'] && !ldap? |