Commit 50a13bc2329184ea85735163ffd3c354c4ef0793

Authored by Gabriel Silva
1 parent 423de2d8

Overrides profile url for Facebook, GitHub, and Google providers

Signed-off-by: Gabriel Silva <gabriel93.silva@gmail.com>
plugins/oauth_client/controllers/public/oauth_client_plugin_public_controller.rb
@@ -32,7 +32,7 @@ class OauthClientPluginPublicController &lt; PublicController @@ -32,7 +32,7 @@ class OauthClientPluginPublicController &lt; PublicController
32 if provider.enabled? 32 if provider.enabled?
33 user = User.new(email: auth.info.email, login: auth.info.name.to_slug) 33 user = User.new(email: auth.info.email, login: auth.info.name.to_slug)
34 webfinger = OpenStruct.new( 34 webfinger = OpenStruct.new(
35 - identifier: user.login, 35 + identifier: auth.info.nickname || user.login,
36 name: auth.info.name, 36 name: auth.info.name,
37 created_at: Time.now, 37 created_at: Time.now,
38 domain: auth.provider, 38 domain: auth.provider,
plugins/oauth_client/lib/ext/external_person.rb
@@ -10,21 +10,19 @@ class ExternalPerson @@ -10,21 +10,19 @@ class ExternalPerson
10 end 10 end
11 11
12 def image 12 def image
13 - ExternalPerson::Image.new(oauth_auth) 13 + ExternalPerson::Image.new(self.oauth_auth)
14 end 14 end
15 15
16 - # This method is un alias to 'url' method of ExternalPerson < ActiveRecord::Base  
17 def public_profile_url 16 def public_profile_url
18 - self.oauth_auth.perfil_url 17 + self.oauth_auth.profile_url
19 end 18 end
20 19
21 -  
22 def url 20 def url
23 - self.oauth_auth.perfil_url 21 + self.oauth_auth.profile_url
24 end 22 end
25 23
26 def admin_url 24 def admin_url
27 - self.oauth_auth.setting_url 25 + self.oauth_auth.settings_url
28 end 26 end
29 27
30 class ExternalPerson::Image 28 class ExternalPerson::Image
plugins/oauth_client/models/oauth_client_plugin/facebook_auth.rb
@@ -5,11 +5,11 @@ class OauthClientPlugin::FacebookAuth &lt; OauthClientPlugin::Auth @@ -5,11 +5,11 @@ class OauthClientPlugin::FacebookAuth &lt; OauthClientPlugin::Auth
5 "#{self.external_person_image_url}?width=#{size}" 5 "#{self.external_person_image_url}?width=#{size}"
6 end 6 end
7 7
8 - def perfil_url  
9 - "https://www.facebook.com/#{self.uid}" 8 + def profile_url
  9 + "https://www.facebook.com/#{self.external_person_uid}"
10 end 10 end
11 11
12 - def setting_url 12 + def settings_url
13 "https://www.facebook.com/settings" 13 "https://www.facebook.com/settings"
14 end 14 end
15 15
plugins/oauth_client/models/oauth_client_plugin/github_auth.rb
@@ -4,4 +4,12 @@ class OauthClientPlugin::GithubAuth &lt; OauthClientPlugin::Auth @@ -4,4 +4,12 @@ class OauthClientPlugin::GithubAuth &lt; OauthClientPlugin::Auth
4 size = IMAGE_SIZES[size] || IMAGE_SIZES[:icon] 4 size = IMAGE_SIZES[size] || IMAGE_SIZES[:icon]
5 "#{self.external_person_image_url}&size=#{size}" 5 "#{self.external_person_image_url}&size=#{size}"
6 end 6 end
  7 +
  8 + def profile_url
  9 + "https://www.github.com/#{self.external_person.identifier}"
  10 + end
  11 +
  12 + def settings_url
  13 + "https://www.github.com/settings"
  14 + end
7 end 15 end
plugins/oauth_client/models/oauth_client_plugin/google_oauth2_auth.rb
@@ -4,4 +4,12 @@ class OauthClientPlugin::GoogleOauth2Auth &lt; OauthClientPlugin::Auth @@ -4,4 +4,12 @@ class OauthClientPlugin::GoogleOauth2Auth &lt; OauthClientPlugin::Auth
4 size = IMAGE_SIZES[size] || IMAGE_SIZES[:icon] 4 size = IMAGE_SIZES[size] || IMAGE_SIZES[:icon]
5 "#{self.external_person_image_url}?sz=#{size}" 5 "#{self.external_person_image_url}?sz=#{size}"
6 end 6 end
  7 +
  8 + def profile_url
  9 + "https://plus.google.com/#{self.external_person_uid}"
  10 + end
  11 +
  12 + def settings_url
  13 + "https://plus.google.com/u/0/settings"
  14 + end
7 end 15 end