fix(web): misleading 2fa registration errors (#2535)

This commit is contained in:
Amir Zarrinkafsh 2021-11-05 15:12:56 +11:00 committed by GitHub
parent 1ea94dd403
commit 0e8ff3bde9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 4 deletions

View File

@ -47,7 +47,15 @@ const RegisterOneTimePassword = function () {
setSecretBase32(secret.base32_secret);
} catch (err) {
console.error(err);
createErrorNotification("Failed to generate the code to register your device", 10000);
if ((err as Error).message.includes("Request failed with status code 403")) {
createErrorNotification(
"You must open the link from the same device and browser that initiated the registration process",
);
} else {
createErrorNotification(
"Failed to register device, the provided link is expired or has already been used",
);
}
setHasErrored(true);
}
setIsLoading(false);

View File

@ -46,10 +46,16 @@ const RegisterSecurityKey = function () {
navigate(FirstFactorPath);
} catch (err) {
console.error(err);
if ((err as Error).message.includes("Request failed with status code 403")) {
createErrorNotification(
"You must open the link from the same device and browser that initiated the registration process",
);
} else {
createErrorNotification(
"Failed to register your security key. The identity verification process might have timed out.",
);
}
}
}, [processToken, createErrorNotification, navigate]);
useEffect(() => {