- redirect_to :action => "new", :nickname => name, :email => email,
- :auth_provider => provider, :auth_uid => uid
+ user = User.find_by(:auth_provider => provider, :auth_uid => uid)
+
+ if user.nil? && provider == "google"
+ openid_url = auth_info[:extra][:id_info]["openid_id"]
+ user = User.find_by(:auth_provider => "openid", :auth_uid => openid_url) if openid_url
+ user.update(:auth_provider => provider, :auth_uid => uid) if user
+ end
+
+ if user
+ case user.status
+ when "pending" then
+ unconfirmed_login(user)
+ when "active", "confirmed" then
+ successful_login(user, request.env["omniauth.params"]["referer"])
+ when "suspended" then
+ failed_login t("user.login.account is suspended", :webmaster => "mailto:#{SUPPORT_EMAIL}").html_safe
+ else
+ failed_login t("user.login.auth failure")
+ end
+ else
+ redirect_to :action => "new", :nickname => name, :email => email,
+ :auth_provider => provider, :auth_uid => uid
+ end