Commit fb903de50828ca01c533e5f02527623ff27a253b

Authored by Dmitriy Zaporozhets
2 parents 4e363c61 054c15e7

Merge pull request #1740 from godric7/master

Enable Oauth login for existing regular users
Showing 1 changed file with 4 additions and 0 deletions   Show diff stats
lib/gitlab/auth.rb
@@ -48,9 +48,13 @@ module Gitlab @@ -48,9 +48,13 @@ module Gitlab
48 48
49 def find_or_new_for_omniauth(auth) 49 def find_or_new_for_omniauth(auth)
50 provider, uid = auth.provider, auth.uid 50 provider, uid = auth.provider, auth.uid
  51 + email = auth.info.email.downcase unless auth.info.email.nil?
51 52
52 if @user = User.find_by_provider_and_extern_uid(provider, uid) 53 if @user = User.find_by_provider_and_extern_uid(provider, uid)
53 @user 54 @user
  55 + elsif @user = User.find_by_email(email)
  56 + @user.update_attributes(:extern_uid => uid, :provider => provider)
  57 + @user
54 else 58 else
55 if Gitlab.config.omniauth['allow_single_sign_on'] 59 if Gitlab.config.omniauth['allow_single_sign_on']
56 @user = create_from_omniauth(auth) 60 @user = create_from_omniauth(auth)