From 65bdb3107bd26cea087211a333829b55803174af Mon Sep 17 00:00:00 2001 From: peintnermax Date: Tue, 30 Apr 2024 10:43:44 +0200 Subject: [PATCH] use v2beta alternative method --- apps/login/app/api/session/route.ts | 13 ++++++------- apps/login/ui/PasswordForm.tsx | 8 ++++---- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/apps/login/app/api/session/route.ts b/apps/login/app/api/session/route.ts index 0525520dd43..29d5167b121 100644 --- a/apps/login/app/api/session/route.ts +++ b/apps/login/app/api/session/route.ts @@ -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, }); }); }) diff --git a/apps/login/ui/PasswordForm.tsx b/apps/login/ui/PasswordForm.tsx index 4e77c5cbe26..899974754b7 100644 --- a/apps/login/ui/PasswordForm.tsx +++ b/apps/login/ui/PasswordForm.tsx @@ -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