FIX: Display generic descriptor for associated account with no info

FIX: Display generic descriptor for associated account with no info

diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml
index 3730c55..ae126b9 100644
--- a/config/locales/server.en.yml
+++ b/config/locales/server.en.yml
@@ -786,6 +786,7 @@ en:
 
   associated_accounts:
     revoke_failed: "Failed to revoke your account with %{provider_name}."
+    connected: "(connected)"
 
   activation:
     action: "Click here to activate your account"
diff --git a/lib/auth/managed_authenticator.rb b/lib/auth/managed_authenticator.rb
index b47e7e1..bdc7f09 100644
--- a/lib/auth/managed_authenticator.rb
+++ b/lib/auth/managed_authenticator.rb
@@ -4,7 +4,7 @@ class Auth::ManagedAuthenticator < Auth::Authenticator
   def description_for_user(user)
     info = UserAssociatedAccount.find_by(provider_name: name, user_id: user.id)&.info
     return "" if info.nil?
-    info["email"] || info["nickname"] || info["name"] || ""
+    info["email"] || info["nickname"] || info["name"] || I18n.t("associated_accounts.connected")
   end
 
   # These three methods are designed to be overriden by child classes
diff --git a/spec/components/auth/managed_authenticator_spec.rb b/spec/components/auth/managed_authenticator_spec.rb
index ea78814..ba463ed 100644
--- a/spec/components/auth/managed_authenticator_spec.rb
+++ b/spec/components/auth/managed_authenticator_spec.rb
@@ -261,6 +261,8 @@ describe Auth::ManagedAuthenticator do
       expect(authenticator.description_for_user(user)).to eq('somenickname')
       association.update(info: { nickname: "bestname" })
       expect(authenticator.description_for_user(user)).to eq('bestname')
+      association.update(info: {})
+      expect(authenticator.description_for_user(user)).to eq(I18n.t("associated_accounts.connected"))
     end
   end

GitHub sha: 5e61893c

1 Like