FEATURE: Use translated name for 'your email has been authenticated by' (#6649)
This commit is contained in:
parent
7e20a0b917
commit
f645cb9c14
|
@ -147,13 +147,13 @@ export default Ember.Controller.extend(
|
|||
);
|
||||
}.property("accountEmail", "authOptions.email", "authOptions.email_valid"),
|
||||
|
||||
authProviderDisplayName(provider) {
|
||||
switch (provider) {
|
||||
case "Google_oauth2":
|
||||
return "Google";
|
||||
default:
|
||||
return provider;
|
||||
}
|
||||
authProviderDisplayName(providerName) {
|
||||
const matchingProvider = findAll().find(provider => {
|
||||
return provider.name === providerName;
|
||||
});
|
||||
return matchingProvider
|
||||
? matchingProvider.get("prettyName")
|
||||
: providerName;
|
||||
},
|
||||
|
||||
prefillUsername: function() {
|
||||
|
|
|
@ -64,8 +64,7 @@ class Auth::Result
|
|||
else
|
||||
result = { email: email,
|
||||
username: UserNameSuggester.suggest(username || name || email),
|
||||
# this feels a tad wrong
|
||||
auth_provider: authenticator_name.capitalize,
|
||||
auth_provider: authenticator_name,
|
||||
email_valid: !!email_valid,
|
||||
omit_username: !!omit_username }
|
||||
|
||||
|
|
|
@ -125,7 +125,7 @@ RSpec.describe Users::OmniauthCallbacksController do
|
|||
|
||||
expect(response_body["email"]).to eq(email)
|
||||
expect(response_body["username"]).to eq("Some_name")
|
||||
expect(response_body["auth_provider"]).to eq("Google_oauth2")
|
||||
expect(response_body["auth_provider"]).to eq("google_oauth2")
|
||||
expect(response_body["email_valid"]).to eq(true)
|
||||
expect(response_body["omit_username"]).to eq(false)
|
||||
expect(response_body["name"]).to eq("Some Name")
|
||||
|
|
|
@ -33,9 +33,7 @@ describe "users/omniauth_callbacks/complete.html.erb" do
|
|||
render
|
||||
|
||||
expect(rendered_data["email"]).to eq(result.email)
|
||||
# TODO this is a bit weird, the upcasing is confusing,
|
||||
# clean it up throughout
|
||||
expect(rendered_data["auth_provider"]).to eq("Cas")
|
||||
expect(rendered_data["auth_provider"]).to eq("CAS")
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -84,3 +84,18 @@ QUnit.test("passwordValidation", function(assert) {
|
|||
testInvalidPassword("porkchops", I18n.t("user.password.same_as_username"));
|
||||
testInvalidPassword("pork@chops.com", I18n.t("user.password.same_as_email"));
|
||||
});
|
||||
|
||||
QUnit.test("authProviderDisplayName", function(assert) {
|
||||
const controller = this.subject({ siteSettings: Discourse.SiteSettings });
|
||||
|
||||
assert.equal(
|
||||
controller.authProviderDisplayName("facebook"),
|
||||
I18n.t("login.facebook.name"),
|
||||
"provider name is translated correctly"
|
||||
);
|
||||
assert.equal(
|
||||
controller.authProviderDisplayName("idontexist"),
|
||||
"idontexist",
|
||||
"provider name falls back if not found"
|
||||
);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue