A platform for community discussion. Free, open, simple.
FIX: Display generic descriptor for associated account with no info
David Taylor5e61893cb27c
diff --git a/config/locales/server.en.yml b/config/locales/server.en.ymlindex 3730c55553d..ae126b9e7ec 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.rbindex b47e7e17d66..bdc7f0951c9 100644--- a/lib/auth/managed_authenticator.rb+++ b/lib/auth/managed_authenticator.rb@@ -4,7 +4,7 @@ class Auth::ManagedAuthenticator < Auth::Authenticatordef description_for_user(user)info = UserAssociatedAccount.find_by(provider_name: name, user_id: user.id)&.inforeturn "" 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 classesdiff --git a/spec/components/auth/managed_authenticator_spec.rb b/spec/components/auth/managed_authenticator_spec.rbindex ea788144a65..ba463ed44e4 100644--- a/spec/components/auth/managed_authenticator_spec.rb+++ b/spec/components/auth/managed_authenticator_spec.rb@@ -261,6 +261,8 @@ describe Auth::ManagedAuthenticator doexpect(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"))endend