mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 11:27:52 +08:00
FEATURE: display associated accounts in admin user
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user