Fix the login template in case no human_name was set on the provider

This commit is contained in:
Quentin Gliech
2023-11-21 15:45:11 +01:00
parent 21c9539e2d
commit 373f4e8d3e
2 changed files with 4 additions and 4 deletions

View File

@@ -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())));

View File

@@ -29,7 +29,7 @@ limitations under the License.
{% if next and next.kind == "link_upstream" %}
<div class="header">
<h1 class="title">{{ _("mas.login.link.headline") }}</h1>
{% 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 %}
<p class="text">{{ _("mas.login.link.description", provider=name) }}</p>
</div>
{% else %}
@@ -81,7 +81,7 @@ limitations under the License.
{% 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 %}
<a class="cpd-button {%- if provider.brand_name %} has-icon {%- endif %}" data-kind="secondary" data-size="lg" href="{{ ('/upstream/authorize/' ~ provider.id ~ params) | prefix_url }}">
{{ logo(provider.brand_name) }}
{{ _("mas.login.continue_with_provider", provider=name) }}