Add more edge-cases to MFA

This commit is contained in:
Tuan Dang
2023-02-15 01:29:40 +07:00
parent 280f482fc8
commit b710944630
6 changed files with 70 additions and 21 deletions
@@ -63,7 +63,6 @@ export default function LoginStep ({
}
} catch (err) {
console.error(err);
setLoginError(true);
}
+21 -1
View File
@@ -30,6 +30,18 @@ const props = {
}
} as const;
interface VerifyMfaTokenError {
response: {
data: {
context: {
code: string;
triesLeft: number;
}
},
status: number;
}
}
/**
* 2nd step of login - users enter their MFA code
* @param {Object} obj
@@ -73,7 +85,15 @@ export default function MFAStep({
}
} catch (err) {
console.error(err);
const error = err as VerifyMfaTokenError;
if (error?.response?.status === 500) {
window.location.reload();
} else if (error?.response?.data?.context?.triesLeft === 0) {
window.location.reload();
router.push('/login');
}
setIsLoading(false);
setCodeError(true);
}