Commit b9526f1b38da0f885e6e9a8b9366b68b8a6f4b1a
1 parent
36eb7356
Overrides external user info for Noosfero and Twitter providers
Signed-off-by: Gabriel Silva <gabriel93.silva@gmail.com> Signed-off-by: Marcos Ronaldo <marcos.rpj2@gmail.com>
Showing
4 changed files
with
23 additions
and
4 deletions
Show diff stats
app/models/external_person.rb
@@ -122,6 +122,10 @@ class ExternalPerson < ActiveRecord::Base | @@ -122,6 +122,10 @@ class ExternalPerson < ActiveRecord::Base | ||
122 | "#{jid(options)}/#{self.name}" | 122 | "#{jid(options)}/#{self.name}" |
123 | end | 123 | end |
124 | 124 | ||
125 | + def name | ||
126 | + "#{self[:name]}@#{self.source}" | ||
127 | + end | ||
128 | + | ||
125 | class ExternalPerson::Image | 129 | class ExternalPerson::Image |
126 | def initialize(path) | 130 | def initialize(path) |
127 | @path = path | 131 | @path = path |
plugins/oauth_client/controllers/public/oauth_client_plugin_public_controller.rb
@@ -35,7 +35,7 @@ class OauthClientPluginPublicController < PublicController | @@ -35,7 +35,7 @@ class OauthClientPluginPublicController < PublicController | ||
35 | identifier: auth.info.nickname || 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: provider.site || auth.provider, |
39 | email: user.email) | 39 | email: user.email) |
40 | person = ExternalPerson.get_or_create(webfinger) | 40 | person = ExternalPerson.get_or_create(webfinger) |
41 | user.external_person_id = person.id | 41 | user.external_person_id = person.id |
plugins/oauth_client/models/oauth_client_plugin/noosfero_oauth2_auth.rb
1 | class OauthClientPlugin::NoosferoOauth2Auth < OauthClientPlugin::Auth | 1 | class OauthClientPlugin::NoosferoOauth2Auth < OauthClientPlugin::Auth |
2 | 2 | ||
3 | def image_url(size = nil) | 3 | def image_url(size = nil) |
4 | - size = IMAGE_SIZES[size] || IMAGE_SIZES[:icon] | ||
5 | - URI.join("http://#{self.external_person.source}/profile/#{self.external_person.identifier}/", size) | 4 | + URI.join("http://#{self.provider.client_options[:site]}/profile/#{self.external_person.identifier}/icon/", size) |
6 | end | 5 | end |
7 | 6 | ||
8 | def profile_url | 7 | def profile_url |
plugins/oauth_client/models/oauth_client_plugin/twitter_auth.rb
1 | class OauthClientPlugin::TwitterAuth < OauthClientPlugin::Auth | 1 | class OauthClientPlugin::TwitterAuth < OauthClientPlugin::Auth |
2 | 2 | ||
3 | + IMAGE_SIZES = { | ||
4 | + :big => "", | ||
5 | + :thumb => "_bigger", | ||
6 | + :portrait => "_normal", | ||
7 | + :minor => "_normal", | ||
8 | + :icon => "_mini" | ||
9 | + } | ||
10 | + | ||
3 | def image_url(size = nil) | 11 | def image_url(size = nil) |
4 | size = IMAGE_SIZES[size] || IMAGE_SIZES[:icon] | 12 | size = IMAGE_SIZES[size] || IMAGE_SIZES[:icon] |
5 | - self.external_person_image_url | 13 | + self.external_person_image_url.gsub("_normal", size) |
14 | + end | ||
15 | + | ||
16 | + def profile_url | ||
17 | + "https://twitter.com/#{self.external_person.identifier}" | ||
18 | + end | ||
19 | + | ||
20 | + def settings_url | ||
21 | + "https://twitter.com/settings" | ||
6 | end | 22 | end |
7 | end | 23 | end |