use v2beta alternative method

This commit is contained in:
peintnermax
2024-04-30 10:43:44 +02:00
parent b01ca12e53
commit 65bdb3107b
2 changed files with 10 additions and 11 deletions

View File

@@ -1,9 +1,9 @@
import {
server,
deleteSession,
listHumanAuthFactors,
getSession,
getUserByID,
listAuthenticationMethodTypes,
} from "#/lib/zitadel";
import {
SessionCookie,
@@ -134,14 +134,13 @@ export async function PUT(request: NextRequest) {
authRequestId
).then(async (session) => {
// if password, check if user has MFA methods
let authFactors;
let authMethods;
if (checks && checks.password && session.factors?.user?.id) {
const response = await listHumanAuthFactors(
server,
const response = await listAuthenticationMethodTypes(
session.factors?.user?.id
);
if (response.result && response.result.length) {
authFactors = response.result;
if (response.authMethodTypes && response.authMethodTypes.length) {
authMethods = response.authMethodTypes;
}
}
@@ -149,7 +148,7 @@ export async function PUT(request: NextRequest) {
sessionId: session.id,
factors: session.factors,
challenges: session.challenges,
authFactors,
authMethods,
});
});
})

View File

@@ -75,7 +75,7 @@ export default function PasswordForm({
// if user has mfa -> /otp/[method] or /u2f
// if mfa is forced and user has no mfa -> /mfa/set
// if no passwordless -> /passkey/add
if (resp.authFactors?.length == 1) {
if (resp.authMethods?.length == 1) {
const params = new URLSearchParams({
loginName: resp.factors.user.loginName,
});
@@ -89,7 +89,7 @@ export default function PasswordForm({
}
let method;
const factor = (resp.authFactors as AuthFactor[])[0];
const factor = (resp.authMethods as AuthFactor[])[0];
if (factor.otp) {
method = "time-based";
return router.push(`/otp/${method}?` + params);
@@ -103,7 +103,7 @@ export default function PasswordForm({
method = "u2f";
return router.push(`/u2f?` + params);
}
} else if (resp.authFactors?.length >= 1) {
} else if (resp.authMethods?.length >= 1) {
const params = new URLSearchParams({
loginName: resp.factors.user.loginName,
});
@@ -117,7 +117,7 @@ export default function PasswordForm({
}
return router.push(`/mfa?` + params);
} else if (loginSettings?.forceMfa && !resp.authFactors?.length) {
} else if (loginSettings?.forceMfa && !resp.authMethods?.length) {
const params = new URLSearchParams({
loginName: resp.factors.user.loginName,
checkAfter: "true", // this defines if the check is directly made after the setup