Avoid false validation when create user
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
parent
5436d6afd6
commit
e6f58cb87d
2 changed files with 2 additions and 3 deletions
|
@ -468,6 +468,6 @@ class User < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_tmp_oauth_email
|
def generate_tmp_oauth_email
|
||||||
self.email = "temp-email-for-oauth-#{username}"
|
self.email = "temp-email-for-oauth-#{username}@gitlab.localhost"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -34,14 +34,13 @@ module Gitlab
|
||||||
# In this case we generate temporary email and force user to fill it later
|
# In this case we generate temporary email and force user to fill it later
|
||||||
if user.email.blank?
|
if user.email.blank?
|
||||||
user.generate_tmp_oauth_email
|
user.generate_tmp_oauth_email
|
||||||
user.save!(validate: false)
|
|
||||||
else
|
else
|
||||||
# Google oauth returns email but dont return nickname
|
# Google oauth returns email but dont return nickname
|
||||||
# So we use part of email as username for new user
|
# So we use part of email as username for new user
|
||||||
user.username = email.match(/^[^@]*/)[0]
|
user.username = email.match(/^[^@]*/)[0]
|
||||||
user.save
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
user.save!
|
||||||
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?
|
||||||
|
|
Loading…
Reference in a new issue