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 32 if provider.enabled?
33 33 user = User.new(email: auth.info.email, login: auth.info.name.to_slug)
34 34 webfinger = OpenStruct.new(
35   - identifier: user.login,
  35 + identifier: auth.info.nickname || user.login,
36 36 name: auth.info.name,
37 37 created_at: Time.now,
38 38 domain: auth.provider,
... ...
plugins/oauth_client/lib/ext/external_person.rb
... ... @@ -10,21 +10,19 @@ class ExternalPerson
10 10 end
11 11  
12 12 def image
13   - ExternalPerson::Image.new(oauth_auth)
  13 + ExternalPerson::Image.new(self.oauth_auth)
14 14 end
15 15  
16   - # This method is un alias to 'url' method of ExternalPerson < ActiveRecord::Base
17 16 def public_profile_url
18   - self.oauth_auth.perfil_url
  17 + self.oauth_auth.profile_url
19 18 end
20 19  
21   -
22 20 def url
23   - self.oauth_auth.perfil_url
  21 + self.oauth_auth.profile_url
24 22 end
25 23  
26 24 def admin_url
27   - self.oauth_auth.setting_url
  25 + self.oauth_auth.settings_url
28 26 end
29 27  
30 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 5 "#{self.external_person_image_url}?width=#{size}"
6 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 10 end
11 11  
12   - def setting_url
  12 + def settings_url
13 13 "https://www.facebook.com/settings"
14 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 size = IMAGE_SIZES[size] || IMAGE_SIZES[:icon]
5 5 "#{self.external_person_image_url}&size=#{size}"
6 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 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 size = IMAGE_SIZES[size] || IMAGE_SIZES[:icon]
5 5 "#{self.external_person_image_url}?sz=#{size}"
6 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 15 end
... ...