Better error for unknown account

Co-authored-by: mrjvs <mistrjvs@gmail.com>
This commit is contained in:
Jip Fr 2023-12-10 22:10:37 +01:00
parent 056fabb266
commit 95c5e73996
3 changed files with 16 additions and 8 deletions

View File

@ -17,7 +17,7 @@
"login": {
"title": "Login to your account",
"description": "Please enter your passphrase to login to your account",
"validationError": "Invalid or incomplete passphrase",
"validationError": "Incorrect or incomplete passphrase",
"deviceLengthError": "Please enter a device name",
"submit": "Login",
"passphraseLabel": "12-Word passphrase",

View File

@ -16,7 +16,7 @@
"passphrasePlaceholder": "Passphrase",
"submit": "Hoist Anchor",
"title": "Hoist the Jolly Roger",
"validationError": "Arr, invalid or incomplete passphrase"
"validationError": "Arr, incorrect or incomplete passphrase"
},
"register": {
"information": {

View File

@ -1,6 +1,7 @@
import { useState } from "react";
import { Trans, useTranslation } from "react-i18next";
import { useAsyncFn } from "react-use";
import type { AsyncReturnType } from "type-fest";
import { verifyValidMnemonic } from "@/backend/accounts/crypto";
import { Button } from "@/components/buttons/Button";
@ -37,12 +38,19 @@ export function LoginFormPart(props: LoginFormPartProps) {
if (validatedDevice.length === 0)
throw new Error(t("auth.login.deviceLengthError") ?? undefined);
const account = await login({
mnemonic: inputMnemonic,
userData: {
device: validatedDevice,
},
});
let account: AsyncReturnType<typeof login>;
try {
account = await login({
mnemonic: inputMnemonic,
userData: {
device: validatedDevice,
},
});
} catch (err) {
if ((err as any).status === 401)
throw new Error(t("auth.login.validationError") ?? undefined);
throw err;
}
await importData(account, progressItems, bookmarkItems);