Avoid false validation when create user

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
Dmitriy Zaporozhets 2014-04-07 16:47:37 +03:00
parent 5436d6afd6
commit e6f58cb87d
No known key found for this signature in database
GPG key ID: 627C5F589F467F17
2 changed files with 2 additions and 3 deletions

View file

@ -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

View file

@ -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?