From 676cbe973456490f4091a8c86341eb1f74ee98a2 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Fri, 8 Feb 2013 11:32:51 +0100 Subject: [PATCH] Update auth.username on relogin if empty. --- app/models/authorization.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/models/authorization.rb b/app/models/authorization.rb index 900013578..79d2572ca 100644 --- a/app/models/authorization.rb +++ b/app/models/authorization.rb @@ -13,6 +13,13 @@ class Authorization < ApplicationModel :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 if hash['info']['image'] user = User.find( auth.user_id ) @@ -41,7 +48,7 @@ class Authorization < ApplicationModel auth = Authorization.create( :user => user, :uid => hash['uid'], - :username => hash['username'], + :username => hash['info']['nickname'] || hash['username'], :provider => hash['provider'], :token => hash['credentials']['token'], :secret => hash['credentials']['secret']