escape mfa checks for passkey auth

This commit is contained in:
Max Peintner
2024-12-30 10:58:22 +01:00
parent 0111673e5a
commit 96a62f59db

View File

@@ -104,6 +104,16 @@ export function checkMFAFactors(
m !== AuthenticationMethodType.PASSKEY,
);
const hasAuthenticatedWithPasskey =
session.factors?.webAuthN?.verifiedAt &&
session.factors?.webAuthN?.userVerified;
// escape further checks if user has authenticated with passkey
if (hasAuthenticatedWithPasskey) {
return;
}
// if user has not authenticated with passkey and has only one additional mfa factor, redirect to that
if (availableMultiFactors?.length == 1) {
const params = new URLSearchParams({
loginName: session.factors?.user?.loginName as string,
@@ -131,7 +141,7 @@ export function checkMFAFactors(
} else if (factor === AuthenticationMethodType.U2F) {
return { redirect: `/u2f?` + params };
}
} else if (availableMultiFactors?.length >= 1) {
} else if (availableMultiFactors?.length > 1) {
const params = new URLSearchParams({
loginName: session.factors?.user?.loginName as string,
});