From 6f986e117a6f8953164a59a1aa2bd9e15dc55c54 Mon Sep 17 00:00:00 2001 From: Quentin Gliech Date: Tue, 21 Nov 2023 15:45:11 +0100 Subject: [PATCH] Fix the login template in case no human_name was set on the provider --- crates/handlers/src/views/login.rs | 4 ++-- templates/pages/login.html | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/handlers/src/views/login.rs b/crates/handlers/src/views/login.rs index d0b088a2a..48d614460 100644 --- a/crates/handlers/src/views/login.rs +++ b/crates/handlers/src/views/login.rs @@ -385,7 +385,7 @@ mod test { &state.clock, UpstreamOAuthProviderParams { issuer: "https://second.com/".to_owned(), - human_name: Some("Second Ltd.".to_owned()), + human_name: None, brand_name: None, scope: [OPENID].into_iter().collect(), token_endpoint_auth_method: OAuthClientAuthenticationMethod::None, @@ -413,7 +413,7 @@ mod test { assert!(response .body() .contains(&escape_html(&first_provider_login.path_and_query()))); - assert!(response.body().contains(&escape_html("Second Ltd."))); + assert!(response.body().contains(&escape_html("second.com"))); assert!(response .body() .contains(&escape_html(&second_provider_login.path_and_query()))); diff --git a/templates/pages/login.html b/templates/pages/login.html index fc23b4607..fe02cbb06 100644 --- a/templates/pages/login.html +++ b/templates/pages/login.html @@ -29,7 +29,7 @@ {% if next and next.kind == "link_upstream" %}

{{ _("mas.login.link.headline") }}

- {% set name = provider.human_name | default(provider.issuer | simplify_url(keep_path=True)) | default(provider.id) %} + {% set name = provider.human_name or (provider.issuer | simplify_url(keep_path=True)) or provider.id %}

{{ _("mas.login.link.description", provider=name) }}

{% else %} @@ -81,7 +81,7 @@

{{ _("mas.login.headline") }}

{% set params = next["params"] | default({}) | to_params(prefix="?") %} {% for provider in providers %} - {% set name = provider.human_name | default(provider.issuer | simplify_url(keep_path=True)) | default(provider.id) %} + {% set name = provider.human_name or (provider.issuer | simplify_url(keep_path=True)) or provider.id %} {{ logo(provider.brand_name) }} {{ _("mas.login.continue_with_provider", provider=name) }}