summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Carstairs <65492573+Sycamost@users.noreply.github.com>2024-01-21 10:09:45 +0000
committerJoe Carstairs <jcarstairs@scottlogic.com>2024-01-29 10:51:49 +0000
commitaabde3ea11ff75513abe5dabd1931a2b76b116c4 (patch)
tree8b3afb6fb0664350171554bc2c50f0c6dd70ea08
parentd6ff3c6aecf53df8a6cf0ac8e8058c2c370106e0 (diff)
Fixes sign-up page
-rw-r--r--src/i18n/translations/pages/signUp/index.ts21
-rw-r--r--src/pages/[locale]/sign-up/index.astro21
2 files changed, 34 insertions, 8 deletions
diff --git a/src/i18n/translations/pages/signUp/index.ts b/src/i18n/translations/pages/signUp/index.ts
index 15a9dcf..ce20313 100644
--- a/src/i18n/translations/pages/signUp/index.ts
+++ b/src/i18n/translations/pages/signUp/index.ts
@@ -17,6 +17,27 @@ const tPage = {
sco: () => 'Sign up',
'en-GB': () => 'Sign up',
},
+ 'status-working': {
+ sco: () => 'Signin you up…',
+ 'en-GB': () => 'Signing you up…',
+ },
+ 'unexpected-error': {
+ sco: () => 'There wis an unexpectit mishanter.',
+ 'en-GB': () => 'There was an expected error.',
+ },
+ 'error-getting-registration-options': {
+ sco: () => 'There wis a mishanter gettin registration options frae the server.',
+ 'en-GB': () => 'There was an error getting registration options from the server.',
+ },
+ 'error-starting-registration': {
+ sco: () => 'There wis a mishanter whan your browser tried tae stert registration.',
+ 'en-GB': () => 'There was an error when your browser tried to start registration.',
+ },
+ 'error-verifying-registration-response': {
+ sco: () =>
+ 'There wis a mishanter whan the server tried tae check that the registration response wis suithfest.',
+ 'en-GB': () => 'There was an error when the server tried to verify the registration response.',
+ },
};
type Raw = typeof tPage;
diff --git a/src/pages/[locale]/sign-up/index.astro b/src/pages/[locale]/sign-up/index.astro
index 5c6c056..b202440 100644
--- a/src/pages/[locale]/sign-up/index.astro
+++ b/src/pages/[locale]/sign-up/index.astro
@@ -34,16 +34,21 @@ const t = translate(locale);
import * as api from '$lib/api';
import { startRegistration } from '@simplewebauthn/browser';
- import UserAlreadyExistsError from '$types/UserAlreadyExistsError.d';
+ import UserAlreadyExistsError from '$types/UserAlreadyExistsError';
+ import RegistrationResponseVerificationFailedError from '$types/RegistrationResponseVerificationFailedError';
import { getLocaleFromDocumentOrThrow } from '$lib/getLocaleFromDocument';
+ import translate from '$i18n/translate';
+ import tPage from '$i18n/translations/pages/signUp';
+
+ const locale = getLocaleFromDocumentOrThrow(document);
+ const t = translate(locale);
const form = document.getElementById('sign-up-form') as HTMLFormElement;
const displayNameInput = document.getElementById('display-name') as HTMLInputElement;
const emailInput = document.getElementById('email') as HTMLInputElement;
const submitButton = document.getElementsByTagName('button')[0] as HTMLButtonElement;
- const locale = getLocaleFromDocumentOrThrow(document);
const statusInfoMsg = document.createElement('p');
- statusInfoMsg.textContent = locale === 'en-GB' ? 'Signing you up…' : 'Signin you up…';
+ statusInfoMsg.textContent = t(tPage, { key: 'status-working' });
const successPageUrl = `/${locale}/sign-up/success`;
@@ -59,7 +64,7 @@ const t = translate(locale);
try {
registrationOptions = await getRegistrationOptions();
} catch (err) {
- reportError('Failed to get registration options.', err);
+ reportError(t(tPage, { key: 'error-getting-registration-options' }), err);
return;
}
@@ -67,7 +72,7 @@ const t = translate(locale);
try {
registrationResponse = await startRegistration(registrationOptions);
} catch (err) {
- reportError('Failed to start registration on the client.', err);
+ reportError(t(tPage, { key: 'error-starting-registration' }), err);
return;
}
@@ -79,7 +84,7 @@ const t = translate(locale);
registrationResponse,
});
} catch (err) {
- reportError('Failed to verify the registration response.', err);
+ reportError(t(tPage, { key: 'error-verifying-registration-response' }), err);
return;
}
@@ -89,7 +94,7 @@ const t = translate(locale);
Failed to verify your registration. Have another go, or contact us at
lallans@hotmail.co.uk if the issue persists.
`,
- null
+ new RegistrationResponseVerificationFailedError(locale)
);
}
@@ -98,7 +103,7 @@ const t = translate(locale);
'?displayName=' +
registrationOptions.user.displayName +
'&userId=' +
- registrationOptions.user.name;
+ registrationOptions.user.id;
console.info(`Redirecting to the success page ${url}...`);
statusInfoMsg.innerHTML =