Skip to content

Commit

Permalink
Catch exception when starting enrollments
Browse files Browse the repository at this point in the history
  • Loading branch information
oharsta committed Jul 11, 2023
1 parent c758089 commit e9b183a
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 26 deletions.
4 changes: 4 additions & 0 deletions account-gui/src/locale/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ I18n.translations.en = {
timeOutInfoFirst: "Your session timed out. Click this ",
timeOutInfoLast: " to try again.",
timeOutInfoLink: "link",
existingRegistration: "Existing registration",
existingRegistrationInfoFirst: "You can't start a new registration as you already have a registration. Click this ",
existingRegistrationInfoLast: " to try to login again.",
existingRegistrationInfoLink: "link",
responseIncorrect: "The response is invalid.",
suspendedResult: "The verification from your eduID app failed. ",
accountNotSuspended: "You can try again.",
Expand Down
4 changes: 4 additions & 0 deletions account-gui/src/locale/nl.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ I18n.translations.nl = {
timeOutInfoFirst: "Je sessie is verlopen. Klik op deze ",
timeOutInfoLast: " om het opnieuw te proberen.",
timeOutInfoLink: "link",
existingRegistration: "Bestaande registrate",
existingRegistrationInfoFirst: "Je kan geen nieuwe registratie starten, omdat je al een registratie hebt. Klik op ",
existingRegistrationInfoLast: " om opnieuw in te loggen.",
existingRegistrationInfoLink: "link",
responseIncorrect: "De code is niet juist.",
suspendedResult: "De verficatie van je eduID app is mislukt. ",
accountNotSuspended: "Je kan het opnieuw proberen.",
Expand Down
16 changes: 15 additions & 1 deletion account-gui/src/routes/EnrollApp.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
let onMobile = "ontouchstart" in document.documentElement;
let status = "NOPE";
let timeOut = false;
let existingRegistration = false;
onDestroy(() => timeOut = true);
Expand Down Expand Up @@ -47,7 +48,11 @@
!timeOut && navigate(`/recovery?h=${hash}`);
})
.catch(() => timeOut = true)
}).catch(() => {
existingRegistration = true;
showSpinner = false;
});
});
</script>
Expand Down Expand Up @@ -81,7 +86,16 @@
{#if showSpinner}
<Spinner/>
{/if}
{#if timeOut}
{#if existingRegistration}
<h2 class="header">{I18n.t("useApp.existingRegistration")}</h2>
<p class="time-out">
<span>{I18n.t("useApp.existingRegistrationInfoFirst")}</span>
<a href={`/login/${hash}`}>
{I18n.t("useApp.existingRegistrationInfoLink")}
</a>
<span>{I18n.t("useApp.existingRegistrationInfoLast")}</span>
</p>
{:else if timeOut}
<h2 class="header">{I18n.t("useApp.timeOut")}</h2>
<p class="time-out">
<span>{I18n.t("useApp.timeOutInfoFirst")}</span>
Expand Down
6 changes: 5 additions & 1 deletion myconext-gui/src/locale/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,11 @@ I18n.translations.en = {
timeOutInfoFirst: "Your session timed out. Click this ",
timeOutInfoLast: " to try again.",
timeOutInfoLink: "link",
openEduIDApp: "Open the app on this device"
openEduIDApp: "Open the app on this device",
existingRegistration: "Existing registration",
existingRegistrationInfoFirst: "You can't start a new registration as you already have a registration. Click this ",
existingRegistrationInfoLast: " to reload your security settings.",
existingRegistrationInfoLink: "link",
},
recovery: {
header: "Set up a recovery method",
Expand Down
6 changes: 5 additions & 1 deletion myconext-gui/src/locale/nl.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,11 @@ I18n.translations.nl = {
timeOutInfoFirst: "Je sessie is verlopen. Klik op deze ",
timeOutInfoLast: " om het opnieuw te proberen.",
timeOutInfoLink: "link",
openEduIDApp: "Open de app op dit apparaat"
openEduIDApp: "Open de app op dit apparaat",
existingRegistration: "Bestaande registrate",
existingRegistrationInfoFirst: "Je kan geen nieuwe registratie starten, omdat je al een registratie hebt. Klik op ",
existingRegistrationInfoLast: " om de instellingen van je beveiliging opnieuw te laden.",
existingRegistrationInfoLink: "link",
},
recovery: {
header: "Een herstelmethode instellen",
Expand Down
64 changes: 41 additions & 23 deletions myconext-gui/src/routes/tiqr/EnrollApp.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,38 @@
let status = "NOPE";
let showSpinner = true;
let timeOut = false;
let existingRegistration = false;
onDestroy(() => timeOut = true);
onMount(() => {
startEnrollment().then(res => {
qrcode = res.qrcode;
url = res.url;
enrollmentKey = res.enrollmentKey;
showSpinner = false;
status = enrollmentStatus.INITIALIZED;
poll({
fn: () => pollEnrollment(enrollmentKey),
validate: currentStatus => {
if (currentStatus === enrollmentStatus.RETRIEVED) {
status = currentStatus;
}
return currentStatus === enrollmentStatus.PROCESSED || timeOut;
},
interval: 1000,
maxAttempts: 60 * 15 // 15 minute timeout
startEnrollment()
.then(res => {
qrcode = res.qrcode;
url = res.url;
enrollmentKey = res.enrollmentKey;
showSpinner = false;
status = enrollmentStatus.INITIALIZED;
poll({
fn: () => pollEnrollment(enrollmentKey),
validate: currentStatus => {
if (currentStatus === enrollmentStatus.RETRIEVED) {
status = currentStatus;
}
return currentStatus === enrollmentStatus.PROCESSED || timeOut;
},
interval: 1000,
maxAttempts: 60 * 15 // 15 minute timeout
})
.then(() => !timeOut && navigate(`/recovery`))
.catch(() => {
timeOut = true;
});
})
.then(() => !timeOut && navigate(`/recovery`))
.catch(() => {
timeOut = true;
});
});
.catch(() => {
existingRegistration = true;
showSpinner = false;
});
});
</script>
Expand Down Expand Up @@ -69,6 +75,7 @@
.mobile-qr-code {
display: flex;
flex-direction: column;
.button-link-container {
margin: auto;
}
Expand All @@ -94,12 +101,23 @@
{/if}
<div class="enroll-app">
<div class="inner-container">
{#if timeOut}
{#if existingRegistration}
<h2 class="header">{I18n.t("enrollApp.existingRegistration")}</h2>
<p class="time-out">
<span>{I18n.t("enrollApp.existingRegistrationInfoFirst")}</span>
<a href="/security">
{I18n.t("enrollApp.existingRegistrationInfoLink")}
</a>
<span>{I18n.t("enrollApp.existingRegistrationInfoLast")}</span>
</p>
{:else if timeOut}
<h2 class="header">{I18n.t("enrollApp.timeOut")}</h2>
<p class="time-out">
<span>{I18n.t("enrollApp.timeOutInfoFirst")}</span>
<a href="/"
on:click|preventDefault|stopPropagation={() => window.location.reload(true)}>{I18n.t("enrollApp.timeOutInfoLink")}</a>
on:click|preventDefault|stopPropagation={() => window.location.reload(true)}>
{I18n.t("enrollApp.timeOutInfoLink")}
</a>
<span>{I18n.t("enrollApp.timeOutInfoLast")}</span>
</p>

Expand Down

0 comments on commit e9b183a

Please sign in to comment.