Skip to content
This repository has been archived by the owner on Sep 10, 2024. It is now read-only.

Commit

Permalink
Fix the login template in case no human_name was set on the provider
Browse files Browse the repository at this point in the history
  • Loading branch information
sandhose committed Nov 21, 2023
1 parent 7d7bcfe commit 6f986e1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions crates/handlers/src/views/login.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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())));
Expand Down
4 changes: 2 additions & 2 deletions templates/pages/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
{% 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 %}
Expand Down Expand Up @@ -81,7 +81,7 @@ <h1 class="title">{{ _("mas.login.headline") }}</h1>

{% 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) }}
Expand Down

0 comments on commit 6f986e1

Please sign in to comment.