Fix login redirect
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Kieran 2023-09-25 21:28:22 +01:00
parent 2f20b90dd9
commit 566f086191
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941
2 changed files with 5 additions and 0 deletions

View File

@ -28,6 +28,7 @@ export default function useLoginHandler() {
if (hexKey.length === 64) {
if (!pin) throw new PinRequiredError();
LoginStore.loginWithPrivateKey(await PinEncrypted.create(hexKey, pin));
return;
} else {
throw new Error("INVALID PRIVATE KEY");
}
@ -39,12 +40,14 @@ export default function useLoginHandler() {
const ent = generateBip39Entropy(key);
const keyHex = entropyToPrivateKey(ent);
LoginStore.loginWithPrivateKey(await PinEncrypted.create(keyHex, pin));
return;
} else if (key.length === 64) {
if (!hasSubtleCrypto) {
throw new Error(insecureMsg);
}
if (!pin) throw new PinRequiredError();
LoginStore.loginWithPrivateKey(await PinEncrypted.create(key, pin));
return;
}
// public key logins

View File

@ -95,12 +95,14 @@ export default function LoginPage() {
}, []);
async function doLogin(pin?: string) {
setError("");
try {
await loginHandler.doLogin(key, pin);
navigate("/");
} catch (e) {
if (e instanceof PinRequiredError) {
setPin(true);
return;
}
if (e instanceof Error) {
setError(e.message);