#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
|
case provider
|
||||||
when 'facebook'
|
when 'facebook'
|
||||||
name = auth['extra']['raw_info']['name']
|
name = auth['extra']['raw_info']['name']
|
||||||
email = auth['info']['email']
|
when 'google_oauth2', 'github'
|
||||||
when 'google_oauth2'
|
name = auth['info']['nickname'] || auth['info']['name']
|
||||||
name = auth['info']['name']
|
|
||||||
email = auth['info']['email']
|
|
||||||
when 'github'
|
|
||||||
name = auth['info']['nickname']
|
|
||||||
email = auth['info']['email']
|
|
||||||
else
|
else
|
||||||
raise 'Provider #{provider} not handled'
|
raise 'Provider #{provider} not handled'
|
||||||
end
|
end
|
||||||
user = User.find_or_initialize_by_email(email)
|
user = User.find_or_initialize_by_email(auth['info']['email'])
|
||||||
if user.new_record?
|
if user.new_record?
|
||||||
user.name = name
|
user.name = name
|
||||||
user.uname = name.gsub(/\s/, '').underscore
|
user.uname = name.gsub(/\s/, '').underscore
|
||||||
|
|
Loading…
Reference in New Issue