diff --git a/app/assets/javascripts/admin/templates/user_index.js.handlebars b/app/assets/javascripts/admin/templates/user_index.js.handlebars
index ca2ed1119..c45f0cf7d 100644
--- a/app/assets/javascripts/admin/templates/user_index.js.handlebars
+++ b/app/assets/javascripts/admin/templates/user_index.js.handlebars
@@ -40,6 +40,11 @@
{{/unless}}
+
{{i18n user.avatar.title}}
{{avatar content imageSize="large"}}
diff --git a/app/models/user.rb b/app/models/user.rb
index d6613f53d..80dc73dd2 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -41,6 +41,7 @@ class User < ActiveRecord::Base
has_one :facebook_user_info, dependent: :destroy
has_one :twitter_user_info, dependent: :destroy
has_one :github_user_info, dependent: :destroy
+ has_one :google_user_info, dependent: :destroy
has_one :oauth2_user_info, dependent: :destroy
has_one :user_stat, dependent: :destroy
has_one :user_profile, dependent: :destroy, inverse_of: :user
@@ -633,6 +634,31 @@ class User < ActiveRecord::Base
user_stat.try(:first_post_created_at)
end
+ def associated_accounts
+ result = []
+ if twitter_user_info
+ result << "Twitter(#{twitter_user_info.screen_name})"
+ end
+
+ if facebook_user_info
+ result << "Facebook(#{facebook_user_info.username})"
+ end
+
+ if google_user_info
+ result << "Google(#{google_user_info.email})"
+ end
+
+ if github_user_info
+ result << "Github(#{github_user_info.screen_name})"
+ end
+
+ user_open_ids.each do |oid|
+ result << "OpenID #{oid.url[0..20]}...(#{oid.email})"
+ end
+
+ result.empty? ? I18n.t("user.no_accounts_associated") : result.join(", ")
+ end
+
protected
def badge_grant
diff --git a/app/serializers/admin_user_serializer.rb b/app/serializers/admin_user_serializer.rb
index dfd429b4d..169ecd301 100644
--- a/app/serializers/admin_user_serializer.rb
+++ b/app/serializers/admin_user_serializer.rb
@@ -24,7 +24,8 @@ class AdminUserSerializer < BasicUserSerializer
:can_activate,
:can_deactivate,
:blocked,
- :time_read
+ :time_read,
+ :associated_accounts
has_one :single_sign_on_record, serializer: SingleSignOnRecordSerializer, embed: :objects
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index b2d954878..d19ddf8a5 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -490,6 +490,7 @@ en:
ok: "Your password looks good."
instructions: "At least %{count} characters."
+ associated_accounts: "Associated accounts"
ip_address:
title: "Last IP Address"
registration_ip_address:
diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml
index 752e1b6e3..ccde610c6 100644
--- a/config/locales/server.en.yml
+++ b/config/locales/server.en.yml
@@ -1108,6 +1108,7 @@ en:
password_too_long: "Passwords are limited to 200 characters."
user:
+ no_accounts_associated: "No accounts associated"
username:
short: "must be at least %{min} characters"
long: "must be no more than %{max} characters"
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 3643799ca..3f85e6d44 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -405,6 +405,22 @@ describe User do
end
end
+ describe 'associated_accounts' do
+ it 'should correctly find social associations' do
+ user = Fabricate(:user)
+ user.associated_accounts.should == I18n.t("user.no_accounts_associated")
+
+ TwitterUserInfo.create(user_id: user.id, screen_name: "sam", twitter_user_id: 1)
+ FacebookUserInfo.create(user_id: user.id, username: "sam", facebook_user_id: 1)
+ GoogleUserInfo.create(user_id: user.id, email: "sam@sam.com", google_user_id: 1)
+ GithubUserInfo.create(user_id: user.id, screen_name: "sam", github_user_id: 1)
+
+ user.reload
+ user.associated_accounts.should == "Twitter(sam), Facebook(sam), Google(sam@sam.com), Github(sam)"
+
+ end
+ end
+
describe 'name heuristics' do
it 'is able to guess a decent name from an email' do
User.suggest_name('sam.saffron@gmail.com').should == 'Sam Saffron'