Skip to content

Commit

Permalink
Show control code after creation
Browse files Browse the repository at this point in the history
  • Loading branch information
oharsta committed Jan 17, 2025
1 parent eb7422a commit 10e2cc9
Show file tree
Hide file tree
Showing 30 changed files with 289 additions and 1,180 deletions.
3 changes: 2 additions & 1 deletion myconext-gui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"svelte-preprocess": "^6.0.3",
"vite": "^6.0.2",
"vite-plugin-svelte-svgr": "^1.0.4",
"vite-plugin-svelte-svg-loader": "^1.0.1"
"vite-plugin-svelte-svg-loader": "^1.0.1",
"@castlenine/svelte-qrcode":"^2.3.0"
},
"resolutions": {
"glob-parent": "^6.0.2",
Expand Down
12 changes: 7 additions & 5 deletions myconext-gui/src/locale/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,6 @@ I18n.translations.en = {
deleteToken: "Revoke access token",
deleted: "eduID removed",
tokenDeleted: "Tokens removed"

},
institution: {
title: "Connected institution",
Expand Down Expand Up @@ -576,7 +575,8 @@ I18n.translations.en = {
issuers: {
eherkenning: "eIDAS",
idin: "Idin",
studielink: "Studielink"
studielink: "Studielink",
servicedesk: "Service Desk"
},
serviceDesk: {
confirmIdentityHeader: "You need to manually confirm your identity",
Expand All @@ -597,12 +597,13 @@ I18n.translations.en = {
information: "Enter your details as they appear on your ID. Names must be in Roman characters.",
lastName: "Last name",
firstName: "First name(s)",
dateOfBirth: "Date of birth",
dayOfBirth: "Date of birth",
generateControlCode: "Generate verification code"
},
controlCode: {
controlCode: "Verification code",
yourControlCode: "Your verification code",
info: "You will also receive an email with this code. The code is valid for 14 days and is intended for:",
info: "You will also receive an email with this code. The code is valid for {{nbr}} more days and is intended for:",
typoPrefix: "Made a typo? ",
typoLink: "Edit your details",
todo: "What's next?",
Expand All @@ -614,7 +615,8 @@ I18n.translations.en = {
deleteControlCode: "Delete verification code",
deletedControlCode: "Verification code deleted",
banner: "Verify your identity at an eduID Service Desk by presenting your ID and verification code.",
showCode: "Show code"
showCode: "Show code",
validityCode: "Your code is valid for {{nbr}} more days."
}
}
}
Expand Down
15 changes: 7 additions & 8 deletions myconext-gui/src/locale/nl.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ I18n.translations.nl = {
passkey: "Passkey",
passkeyAdd: "Voeg een passkey toe"
},

tiqr: {
title: "Wil je de volgende keer sneller en veiliger inloggen?",
info: "Download de <strong>eduID app</strong> en log veilig in zonder wachtwoord of toegang tot je e-mail.",
Expand All @@ -221,7 +220,6 @@ I18n.translations.nl = {
getCode: "Vraag een code aan",
codeInfo: "Hopelijk bewaard op een veilige plek",
getCodeInfo: "En bewaar het op een veilige plek",

}
},
home: {
Expand Down Expand Up @@ -353,7 +351,6 @@ I18n.translations.nl = {
flash: {
passwordLink: "Een e-mail is verstuurd naar {{name}} om je wachtwoord opnieuw in te stellen."
}

},
webauthn: {
setTitle: "Beveiligingssleutel toevoegen",
Expand Down Expand Up @@ -413,7 +410,6 @@ I18n.translations.nl = {
maxAttemptsPost: "om opnieuw je telefoonnummer in te voeren en een nieuwe code te ontvangen",
maxAttemptsPostNoReEnter: "om een nieuwe code aan te vragen",
here: " hier "

},
enrollApp: {
header: "Voltooi de installatie in de eduID app",
Expand Down Expand Up @@ -579,7 +575,8 @@ I18n.translations.nl = {
issuers: {
eherkenning: "eIDAS",
idin: "Idin",
studielink: "Studielink"
studielink: "Studielink",
servicedesk: "Service Desk"
},
serviceDesk: {
confirmIdentityHeader: "Bevestig wie je bent met je identiteitsbewijs",
Expand All @@ -600,12 +597,13 @@ I18n.translations.nl = {
information: "Vul je gegevens in zoals die op je identiteitsbewijs staan.",
lastName: "Achternaam",
firstName: "Voornamen",
dateOfBirth: "Geboortedatum",
dayOfBirth: "Geboortedatum",
generateControlCode: "Genereer controlcode"
},
controlCode: {
controlCode: "Controlecode",
yourControlCode: "Je controlecode",
info: "Je krijgt ook een e-mail met deze code. De code is 14 dagen geldig en is bedoeld voor:",
info: "Je krijgt ook een e-mail met deze code. De code is {{nbr}} dagen geldig en is bedoeld voor:",
typoPrefix: "Typfout gemaakt? ",
typoLink: "Pas gegevens aan",
todo: "Wat moet je nu doen?",
Expand All @@ -617,7 +615,8 @@ I18n.translations.nl = {
deleteControlCode: "Verwijder controlecode",
deletedControlCode: "Verificatie-code verwijderd",
banner: "Bevestig je identiteit bij een eduID Service Desk. Dit doe je door je identiteitsbewijs en controlecode te laten zien.",
showCode: "Toon code"
showCode: "Toon code",
validityCode: "Je code is nog geldig voor {{nbr}} dagen."
}
},
}
Expand Down
72 changes: 34 additions & 38 deletions myconext-gui/src/routes/PersonalInfo.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import alertSvg from "../icons/alert-circle.svg?raw";
import Button from "../components/Button.svelte";
import {
deleteLinkedAccount, deleteUserControlCode,
deleteLinkedAccount,
iDINIssuers,
preferLinkedAccount,
startLinkAccountFlow,
Expand Down Expand Up @@ -61,7 +61,7 @@
let showControlCode = false;
const manageVerifiedInformation = path => {
navigate(`/${path}`, {replace:true});
navigate(`/${path}`, {replace: true});
}
const preferInstitution = (showConfirmation, linkedAccount) => {
Expand Down Expand Up @@ -136,7 +136,7 @@
}
}
const refresh = (retry=false) => {
const refresh = (retry = false) => {
($user.linkedAccounts || []).forEach(account => markExpired(account));
($user.externalLinkedAccounts || []).forEach(account => markExternalLinkedAccountExpired(account));
sortedAccounts = ($user.linkedAccounts || []).sort((a, b) => b.createdAt - a.createdAt);
Expand Down Expand Up @@ -213,6 +213,7 @@
showModal = false;
showNewInstitutionModal = false;
showPreferredInstitutionModal = false;
showControlCode = false;
const url = new URL(window.location.href);
url.search = "";
history.pushState({}, "", url.toString());
Expand All @@ -233,20 +234,20 @@
const newExternalAccountLinked = !isEmpty(verify) && !isEmpty($user.externalLinkedAccounts);
if (newAccountLinked || newExternalAccountLinked) {
//Determine if the new account is external or not
const newAccount = newExternalAccountLinked ?
$user.externalLinkedAccounts[0] :
($user.linkedAccounts || [])
.find(la => la.eduPersonPrincipalName === linkedAccountIdentifier || la.subjectId === linkedAccountIdentifier);
if (newAccount && (newExternalAccountLinked || !isEmpty(newAccount.givenName) || !isEmpty(newAccount.familyName))) {
newInstitution = newAccount;
if ((($user.linkedAccounts || []).length + ($user.externalLinkedAccounts || []).length) === 1) {
showNewInstitutionModal = true;
} else {
preferInstitution(true, newAccount);
}
//Determine if the new account is external or not
const newAccount = newExternalAccountLinked ?
$user.externalLinkedAccounts[0] :
($user.linkedAccounts || [])
.find(la => la.eduPersonPrincipalName === linkedAccountIdentifier || la.subjectId === linkedAccountIdentifier);
if (newAccount && (newExternalAccountLinked || !isEmpty(newAccount.givenName) || !isEmpty(newAccount.familyName))) {
newInstitution = newAccount;
if ((($user.linkedAccounts || []).length + ($user.externalLinkedAccounts || []).length) === 1) {
showNewInstitutionModal = true;
} else {
preferInstitution(true, newAccount);
}
}
}
if (!isEmpty(retry)) {
addIdentity(true);
Expand Down Expand Up @@ -357,8 +358,9 @@
font-size: 22px;
font-family: Nunito, sans-serif;
color: var(--color-primary-green);
&.second {
margin: 25px 0 15px 0;
margin: 25px 0 15px 0;
}
}
Expand Down Expand Up @@ -399,6 +401,7 @@
@media (max-width: $max-width-mobile) {
margin-left: 0;
}
:global(svg) {
height: 28px;
width: auto;
Expand Down Expand Up @@ -476,10 +479,15 @@
display: flex;
flex-direction: column;
padding: 25px;
span {
margin: auto;
font-size: 34px;
letter-spacing: 6px;
&.code {
font-size: 34px;
margin-bottom: 40px;
letter-spacing: 6px;
}
}
}
Expand All @@ -489,12 +497,12 @@
{#if showManageVerifiedInformation}
<div class="inner-container">
<div class="verified-information">
<div class="with-icon">
<div class="with-icon">
<span class="back" on:click={() => manageVerifiedInformation("personal")}>
{@html arrowLeft}
</span>
<h2>{I18n.t("profile.verifiedInformation")}</h2>
</div>
<h2>{I18n.t("profile.verifiedInformation")}</h2>
</div>
<p class="info">{I18n.t("profile.verifiedInformationInfo")}</p>
<div class="preferred-info">
{@html personalInfo}
Expand Down Expand Up @@ -648,16 +656,18 @@
</Modal>
{/if}

{#if showModal}
{#if showModal || showControlCode}
<Modal close={() => resetModalsAndQueryParams()}
title={showIdinOptions ? I18n.t("verify.modal.header") : I18n.t("profile.addInstitution")}
title={showIdinOptions ? I18n.t("verify.modal.header") : showControlCode ?
I18n.t("verify.serviceDesk.controlCode.controlCode") : I18n.t("profile.addInstitution")}
showOptions={false}>
<VerifyChoice addInstitution={addInstitution}
addBank={addBank}
addEuropean={addEuropean}
issuers={issuers}
showIdinOptions={showIdinOptions}
showServiceDesk={serviceDeskStart}
showControlCode={showControlCode}
cancel={() => resetModalsAndQueryParams()}/>
</Modal>
{/if}
Expand Down Expand Up @@ -693,17 +703,3 @@
/>
</Modal>
{/if}

{#if showControlCode}
<Modal submit={() => showControlCode = false}
close={() => showControlCode = false}
cancelTitle={I18n.t("verify.serviceDesk.controlCode.deleteControlCode")}
largeConfirmation={true}
confirmTitle={I18n.t("profile.ok")}
title={I18n.t("verify.serviceDesk.controlCode.yourControlCode")}>
<div class="control-code">
<span>{$user.controlCode.code}</span>
</div>
</Modal>
{/if}

5 changes: 5 additions & 0 deletions myconext-gui/src/utils/date.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,8 @@ export function dateFromEpoch(epochMilli, includeTime = false) {
const timeFormatted = ` ${I18n.t("security.tiqr.dateTimeOn")} ${date.getHours()}:${minutesFormatted}`;
return `${dateFormatted}${timeFormatted}`
}

export function verificationCodeValidityDays(controlCode) {
const millis = new Date().getTime() - controlCode.createdAt || new Date().getTime();
return Math.floor(millis / (1000 * 60 * 60 * 24)) + 14;
}
Loading

0 comments on commit 10e2cc9

Please sign in to comment.