Update auth.username on relogin if empty.

This commit is contained in:
Martin Edenhofer 2013-02-08 11:32:51 +01:00
parent f6545672ee
commit 676cbe9734

View file

@ -13,6 +13,13 @@ class Authorization < ApplicationModel
:secret => hash['credentials']['secret'] :secret => hash['credentials']['secret']
) )
# update username of auth entry if empty
if !auth.username && hash['info']['nickname']
auth.update_attributes(
:username => hash['info']['nickname'],
)
end
# update image if needed # update image if needed
if hash['info']['image'] if hash['info']['image']
user = User.find( auth.user_id ) user = User.find( auth.user_id )
@ -41,7 +48,7 @@ class Authorization < ApplicationModel
auth = Authorization.create( auth = Authorization.create(
:user => user, :user => user,
:uid => hash['uid'], :uid => hash['uid'],
:username => hash['username'], :username => hash['info']['nickname'] || hash['username'],
:provider => hash['provider'], :provider => hash['provider'],
:token => hash['credentials']['token'], :token => hash['credentials']['token'],
:secret => hash['credentials']['secret'] :secret => hash['credentials']['secret']