diff --git a/frontend/src/pages/login/login.ts b/frontend/src/pages/login/login.ts index 1cb11e5..f0fb8e1 100644 --- a/frontend/src/pages/login/login.ts +++ b/frontend/src/pages/login/login.ts @@ -92,7 +92,7 @@ async function handleOtp( }); navigateTo(returnTo ?? "/"); } else if (res.kind === "failed") { - showError(`Failed to authenticate: ${res.msg}`); + showError(`Failed to authenticate`); } } } diff --git a/frontend/src/pages/profile/profile.ts b/frontend/src/pages/profile/profile.ts index cb19311..c1e59fd 100644 --- a/frontend/src/pages/profile/profile.ts +++ b/frontend/src/pages/profile/profile.ts @@ -221,7 +221,7 @@ async function route(url: string, _args: { [k: string]: string }) { if (res.kind === "success") { navigateTo(url); } else { - showError(`failed to activate OTP: ${res.msg}`); + showError(`failed to activate OTP`); } }; @@ -230,7 +230,7 @@ async function route(url: string, _args: { [k: string]: string }) { if (res.kind === "success") { navigateTo(url); } else { - showError(`failed to deactivate OTP: ${res.msg}`); + showError(`failed to deactivate OTP`); } }; @@ -252,7 +252,7 @@ async function route(url: string, _args: { [k: string]: string }) { showSuccess("Successfully changed display name"); handleRoute(); } else { - showError(`Failed to update: ${req.msg}`); + showError(`Failed to update`); } }; passwordButton.onclick = async () => { @@ -265,7 +265,7 @@ async function route(url: string, _args: { [k: string]: string }) { showSuccess("Successfully changed password"); handleRoute(); } else { - showError(`Failed to update: ${req.msg}`); + showError(`Failed to update`); } }; descButton.onclick = async () => { @@ -275,7 +275,7 @@ async function route(url: string, _args: { [k: string]: string }) { handleRoute(); } else { - showError(`Failed to update: ${req.msg}`); + showError(`Failed to update`); } }; diff --git a/frontend/src/pages/signin/signin.ts b/frontend/src/pages/signin/signin.ts index cb34c42..8e60837 100644 --- a/frontend/src/pages/signin/signin.ts +++ b/frontend/src/pages/signin/signin.ts @@ -8,6 +8,17 @@ import loggedInHtml from './alreadyLoggedin.html?raw'; import { isNullish } from "@app/utils"; import cuteCat from './cuteCat.png'; +const MSG_KEY_TO_STRING = { + 'signin.failed.username.existing': 'Username already exists', + 'signin.failed.username.toolong': 'Username is too short', + 'signin.failed.username.tooshort': 'Username is too long', + 'signin.failed.username.invalid': 'Username is invalid', + 'signin.failed.password.toolong': 'Password is too long', + 'signin.failed.password.tooshort': 'Password is too short', + 'signin.failed.password.invalid': 'Password is invalid', + 'signin.failed.generic': 'Unknown Error', +}; + async function handleSignin(_url: string, _args: RouteHandlerParams): Promise { setTitle('Signin') let user = await updateUser(); @@ -72,7 +83,7 @@ async function handleSignin(_url: string, _args: RouteHandlerParams): Promise navigateTo('/') } @@ -79,7 +79,7 @@ async function tourHistorySingle(_url: string, args: RouteHandlerParams): Promis let data = await client.tournamentData({ id: args.tourid }); if (data.kind !== 'success') { - showError(`Failed to fetch data: ${data.msg}`); + showError(`Failed to fetch data`); return { html: "", postInsert: async () => navigateTo('/') }