#30: refactoring of OmniauthCallbacksController#find_for_ouath
This commit is contained in:
parent
69c226be0b
commit
960aecb6d5
|
@ -41,17 +41,12 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
|||
case provider
|
||||
when 'facebook'
|
||||
name = auth['extra']['raw_info']['name']
|
||||
email = auth['info']['email']
|
||||
when 'google_oauth2'
|
||||
name = auth['info']['name']
|
||||
email = auth['info']['email']
|
||||
when 'github'
|
||||
name = auth['info']['nickname']
|
||||
email = auth['info']['email']
|
||||
when 'google_oauth2', 'github'
|
||||
name = auth['info']['nickname'] || auth['info']['name']
|
||||
else
|
||||
raise 'Provider #{provider} not handled'
|
||||
end
|
||||
user = User.find_or_initialize_by_email(email)
|
||||
user = User.find_or_initialize_by_email(auth['info']['email'])
|
||||
if user.new_record?
|
||||
user.name = name
|
||||
user.uname = name.gsub(/\s/, '').underscore
|
||||
|
|
Loading…
Reference in New Issue