webauthn: update login flow to support other 2fa methods

This commit is contained in:
Matthew Penner
2021-07-17 12:48:14 -06:00
parent 42a3e740ba
commit 31c2ef5279
13 changed files with 255 additions and 41 deletions

View File

@@ -39,19 +39,37 @@ const LoginContainer = ({ history }: RouteComponentProps) => {
setSubmitting(false);
clearAndAddHttpError({ error });
});
return;
}
login({ ...values, recaptchaData: token })
.then(response => {
console.log('wow!');
console.log(response);
if (response.complete) {
console.log(`Redirecting to: ${response.intended || '/'}`);
// @ts-ignore
window.location = response.intended || '/';
return;
}
history.replace('/auth/login/checkpoint', { token: response.confirmationToken });
if (response.methods?.includes('webauthn')) {
console.log('Redirecting to: /auth/login/key');
history.replace('/auth/login/key', {
token: response.confirmationToken,
publicKey: response.publicKey,
hasTotp: response.methods.includes('totp'),
});
return;
}
if (response.methods?.includes('totp')) {
console.log('/auth/login/checkpoint');
history.replace('/auth/login/checkpoint', { token: response.confirmationToken });
return;
}
console.log('huh?');
})
.catch(error => {
console.error(error);