From 50a13bc2329184ea85735163ffd3c354c4ef0793 Mon Sep 17 00:00:00 2001 From: Gabriel Silva Date: Thu, 28 Jul 2016 16:56:47 +0000 Subject: [PATCH] Overrides profile url for Facebook, GitHub, and Google providers --- plugins/oauth_client/controllers/public/oauth_client_plugin_public_controller.rb | 2 +- plugins/oauth_client/lib/ext/external_person.rb | 10 ++++------ plugins/oauth_client/models/oauth_client_plugin/facebook_auth.rb | 6 +++--- plugins/oauth_client/models/oauth_client_plugin/github_auth.rb | 8 ++++++++ plugins/oauth_client/models/oauth_client_plugin/google_oauth2_auth.rb | 8 ++++++++ 5 files changed, 24 insertions(+), 10 deletions(-) diff --git a/plugins/oauth_client/controllers/public/oauth_client_plugin_public_controller.rb b/plugins/oauth_client/controllers/public/oauth_client_plugin_public_controller.rb index 074ce16..6f8665a 100644 --- a/plugins/oauth_client/controllers/public/oauth_client_plugin_public_controller.rb +++ b/plugins/oauth_client/controllers/public/oauth_client_plugin_public_controller.rb @@ -32,7 +32,7 @@ class OauthClientPluginPublicController < PublicController if provider.enabled? user = User.new(email: auth.info.email, login: auth.info.name.to_slug) webfinger = OpenStruct.new( - identifier: user.login, + identifier: auth.info.nickname || user.login, name: auth.info.name, created_at: Time.now, domain: auth.provider, diff --git a/plugins/oauth_client/lib/ext/external_person.rb b/plugins/oauth_client/lib/ext/external_person.rb index 0de5993..14639e7 100644 --- a/plugins/oauth_client/lib/ext/external_person.rb +++ b/plugins/oauth_client/lib/ext/external_person.rb @@ -10,21 +10,19 @@ class ExternalPerson end def image - ExternalPerson::Image.new(oauth_auth) + ExternalPerson::Image.new(self.oauth_auth) end - # This method is un alias to 'url' method of ExternalPerson < ActiveRecord::Base def public_profile_url - self.oauth_auth.perfil_url + self.oauth_auth.profile_url end - def url - self.oauth_auth.perfil_url + self.oauth_auth.profile_url end def admin_url - self.oauth_auth.setting_url + self.oauth_auth.settings_url end class ExternalPerson::Image diff --git a/plugins/oauth_client/models/oauth_client_plugin/facebook_auth.rb b/plugins/oauth_client/models/oauth_client_plugin/facebook_auth.rb index 80025bd..24314ae 100644 --- a/plugins/oauth_client/models/oauth_client_plugin/facebook_auth.rb +++ b/plugins/oauth_client/models/oauth_client_plugin/facebook_auth.rb @@ -5,11 +5,11 @@ class OauthClientPlugin::FacebookAuth < OauthClientPlugin::Auth "#{self.external_person_image_url}?width=#{size}" end - def perfil_url - "https://www.facebook.com/#{self.uid}" + def profile_url + "https://www.facebook.com/#{self.external_person_uid}" end - def setting_url + def settings_url "https://www.facebook.com/settings" end diff --git a/plugins/oauth_client/models/oauth_client_plugin/github_auth.rb b/plugins/oauth_client/models/oauth_client_plugin/github_auth.rb index 7c52aca..f7891ad 100644 --- a/plugins/oauth_client/models/oauth_client_plugin/github_auth.rb +++ b/plugins/oauth_client/models/oauth_client_plugin/github_auth.rb @@ -4,4 +4,12 @@ class OauthClientPlugin::GithubAuth < OauthClientPlugin::Auth size = IMAGE_SIZES[size] || IMAGE_SIZES[:icon] "#{self.external_person_image_url}&size=#{size}" end + + def profile_url + "https://www.github.com/#{self.external_person.identifier}" + end + + def settings_url + "https://www.github.com/settings" + end end diff --git a/plugins/oauth_client/models/oauth_client_plugin/google_oauth2_auth.rb b/plugins/oauth_client/models/oauth_client_plugin/google_oauth2_auth.rb index f891db7..e024495 100644 --- a/plugins/oauth_client/models/oauth_client_plugin/google_oauth2_auth.rb +++ b/plugins/oauth_client/models/oauth_client_plugin/google_oauth2_auth.rb @@ -4,4 +4,12 @@ class OauthClientPlugin::GoogleOauth2Auth < OauthClientPlugin::Auth size = IMAGE_SIZES[size] || IMAGE_SIZES[:icon] "#{self.external_person_image_url}?sz=#{size}" end + + def profile_url + "https://plus.google.com/#{self.external_person_uid}" + end + + def settings_url + "https://plus.google.com/u/0/settings" + end end -- libgit2 0.21.2