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

pull/2534/head
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); setSecretBase32(secret.base32_secret);
} catch (err) { } catch (err) {
console.error(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); setHasErrored(true);
} }
setIsLoading(false); setIsLoading(false);

View File

@ -46,9 +46,15 @@ const RegisterSecurityKey = function () {
navigate(FirstFactorPath); navigate(FirstFactorPath);
} catch (err) { } catch (err) {
console.error(err); console.error(err);
createErrorNotification( if ((err as Error).message.includes("Request failed with status code 403")) {
"Failed to register your security key. The identity verification process might have timed out.", 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]); }, [processToken, createErrorNotification, navigate]);