Skip to content
Snippets Groups Projects
Commit f93e2029 authored by Giovanne Marcelo's avatar Giovanne Marcelo
Browse files

hotfix in oauth login

parent 844d7240
No related branches found
No related tags found
No related merge requests found
......@@ -77,13 +77,23 @@ require 'open-uri'
# break out provider attribute assignment for easy method extension
def assign_provider_attrs(user, auth_hash)
avatar = auth_hash['provider']=='google_oauth2' ? open(auth_hash['info']['image']) : auth_hash['info']['image']
email = auth_hash['info']['email']
avatar = auth_hash['info']['image']
# Duplicate emails when logging via facebook and google cause API to crash
# Add +google_oauth2 to google logins to avoid duplication (workaround!!)
# Google ignore strings after '+' until '@gmail.com' (wow!!!)
if auth_hash['provider']=='google_oauth2'
email = auth_hash['info']['email'].split('@')[0] + '+' + auth_hash['provider'] + '@' + auth_hash['info']['email'].split('@')[1]
avatar = open(auth_hash['info']['image'])
end
user.assign_attributes({
nickname: auth_hash['info']['nickname'],
name: auth_hash['info']['name'],
avatar: avatar,
email: auth_hash['info']['email'] + auth_hash['provider']
email: email
})
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment