Fix login redirect
This commit is contained in:
parent
2f20b90dd9
commit
566f086191
@ -28,6 +28,7 @@ export default function useLoginHandler() {
|
|||||||
if (hexKey.length === 64) {
|
if (hexKey.length === 64) {
|
||||||
if (!pin) throw new PinRequiredError();
|
if (!pin) throw new PinRequiredError();
|
||||||
LoginStore.loginWithPrivateKey(await PinEncrypted.create(hexKey, pin));
|
LoginStore.loginWithPrivateKey(await PinEncrypted.create(hexKey, pin));
|
||||||
|
return;
|
||||||
} else {
|
} else {
|
||||||
throw new Error("INVALID PRIVATE KEY");
|
throw new Error("INVALID PRIVATE KEY");
|
||||||
}
|
}
|
||||||
@ -39,12 +40,14 @@ export default function useLoginHandler() {
|
|||||||
const ent = generateBip39Entropy(key);
|
const ent = generateBip39Entropy(key);
|
||||||
const keyHex = entropyToPrivateKey(ent);
|
const keyHex = entropyToPrivateKey(ent);
|
||||||
LoginStore.loginWithPrivateKey(await PinEncrypted.create(keyHex, pin));
|
LoginStore.loginWithPrivateKey(await PinEncrypted.create(keyHex, pin));
|
||||||
|
return;
|
||||||
} else if (key.length === 64) {
|
} else if (key.length === 64) {
|
||||||
if (!hasSubtleCrypto) {
|
if (!hasSubtleCrypto) {
|
||||||
throw new Error(insecureMsg);
|
throw new Error(insecureMsg);
|
||||||
}
|
}
|
||||||
if (!pin) throw new PinRequiredError();
|
if (!pin) throw new PinRequiredError();
|
||||||
LoginStore.loginWithPrivateKey(await PinEncrypted.create(key, pin));
|
LoginStore.loginWithPrivateKey(await PinEncrypted.create(key, pin));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public key logins
|
// public key logins
|
||||||
|
@ -95,12 +95,14 @@ export default function LoginPage() {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
async function doLogin(pin?: string) {
|
async function doLogin(pin?: string) {
|
||||||
|
setError("");
|
||||||
try {
|
try {
|
||||||
await loginHandler.doLogin(key, pin);
|
await loginHandler.doLogin(key, pin);
|
||||||
navigate("/");
|
navigate("/");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof PinRequiredError) {
|
if (e instanceof PinRequiredError) {
|
||||||
setPin(true);
|
setPin(true);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (e instanceof Error) {
|
if (e instanceof Error) {
|
||||||
setError(e.message);
|
setError(e.message);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user