Skip to content

Commit

Permalink
Merge pull request #346 from OpenConext/feature/342-open-in-app-button
Browse files Browse the repository at this point in the history
Add 'Open in app' button below QR code
  • Loading branch information
johanib authored Feb 4, 2025
2 parents de256fd + 4d55755 commit 483132c
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 0 deletions.
10 changes: 10 additions & 0 deletions assets/scss/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,16 @@ div.middle {

}

#open-in-app {
text-align: center;
margin-bottom: 1.5rem;
}

#open-in-app a {
display: inline-block;
margin: 0 auto;
}

#otpform {
width: 50%;
margin: 0 auto;
Expand Down
27 changes: 27 additions & 0 deletions assets/typescript/Component/MobileOnlyComponent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import 'jquery';
import {Component} from './Component';

export class MobileOnlyComponent implements Component {

private readonly onMobile;

constructor(private element: JQuery) {
this.onMobile = "ontouchstart" in document.documentElement;

if (this.onMobile) {
this.show();
} else {
this.hide();
}
}

public show() {
if (this.onMobile) {
this.element.show();
}
}

public hide() {
this.element.hide();
}
}
2 changes: 2 additions & 0 deletions assets/typescript/authentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { AuthenticationPageService } from './AuthenticationPageService';
import { NotificationClient } from './Client/NotificationClient';
import { SlideableComponent } from './Component/SlideableComponent';
import { HideableComponent } from './Component/HideableComponent';
import { MobileOnlyComponent } from "./Component/MobileOnlyComponent";
import jQuery from 'jquery';

declare global {
Expand All @@ -23,6 +24,7 @@ window.bootstrapAuthentication = (statusApiUrl: string, notificationApiUrl: stri
const challengeExpiredComponent = new HideableComponent(jQuery('#challengeExpired'));
const statusErrorComponent = new HideableComponent(jQuery('#status-request-error'));
const notificationErrorComponent = new HideableComponent(jQuery('#notificationError'));
new MobileOnlyComponent(jQuery('#open-in-app'));

const authenticationPageService = new AuthenticationPageService(
pollingService,
Expand Down
4 changes: 4 additions & 0 deletions assets/typescript/registration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { StatusClient } from './Client/StatusClient';
import { StatusPollService } from './StatusPollService';
import { RegistrationStatusComponent } from './Component/RegistrationStatusComponent';
import { SlideableComponent } from './Component/SlideableComponent';
import { MobileOnlyComponent } from "./Component/MobileOnlyComponent";
import jQuery from 'jquery';

declare global {
Expand All @@ -25,5 +26,8 @@ window.bootstrapRegistration = (statusApiUrl: string, finalizedUrl: string, corr
finalizedUrl,
);
machine.start();

new MobileOnlyComponent(jQuery('#open-in-app'));

return machine;
};
6 changes: 6 additions & 0 deletions templates/default/authentication.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@
<img src="{{ url('app_identity_authentication_qr') }}">
</a>

<div id="open-in-app" style="display: none;">
<a class="btn btn-primary" href="{{ authenticateUrl }}">
{{ 'open_tiqr_app' | trans }}
</a>
</div>

{{ 'login.qr.manual.message' | trans }} <a
onClick="authenticationPageService.switchToOtp()">{{ 'login.qr.manual.here' | trans }}</a>.
</div>
Expand Down
7 changes: 7 additions & 0 deletions templates/default/registration.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@
<a href="{{ metadataUrl }}">
<img src="{{ url('app_identity_registration_qr', {'enrollmentKey': enrollmentKey}) }}">
</a>

<div id="open-in-app" style="display: none;">
<a class="btn btn-primary" href="{{ metadataUrl }}">
{{ 'open_tiqr_app' | trans }}
</a>
</div>

{{ 'enrol.download' | trans | raw }}
</div>
{% endblock %}
1 change: 1 addition & 0 deletions translations/messages.en.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
open_tiqr_app: Open the app on this device
login:
title: Log in with tiqr
challenge_expired: Login timeout. Try again or refresh this page.
Expand Down
1 change: 1 addition & 0 deletions translations/messages.nl.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
en: Engels
nl: Nederlands
open_tiqr_app: Open de app op dit apparaat
login:
title: Log in met tiqr
challenge_expired: Login timeout. Ververs de pagina om het nogmaals te proberen.
Expand Down

0 comments on commit 483132c

Please sign in to comment.