mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-25 12:18:54 +00:00
catch already handled
This commit is contained in:
@@ -48,6 +48,8 @@ async function isSessionValid(
|
|||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
let mfaValid = true;
|
let mfaValid = true;
|
||||||
if (checkLoginSettings && session.factors?.user?.organizationId) {
|
if (checkLoginSettings && session.factors?.user?.organizationId) {
|
||||||
|
// TODO: check for auth methods of the user to know if the session has all required mfa methods
|
||||||
|
|
||||||
const loginSettings = await getLoginSettings(
|
const loginSettings = await getLoginSettings(
|
||||||
session.factors?.user?.organizationId,
|
session.factors?.user?.organizationId,
|
||||||
);
|
);
|
||||||
@@ -172,8 +174,33 @@ export async function GET(request: NextRequest) {
|
|||||||
{ status: 500 },
|
{ status: 500 },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error: unknown) {
|
||||||
return NextResponse.json({ error }, { status: 500 });
|
// handle already handled gracefully as these could come up if old emails with authRequestId are used (reset password, register emails etc.)
|
||||||
|
console.error(error);
|
||||||
|
if (
|
||||||
|
error &&
|
||||||
|
typeof error === "object" &&
|
||||||
|
"code" in error &&
|
||||||
|
error?.code === 9
|
||||||
|
) {
|
||||||
|
const signedinUrl = new URL("/signedin", request.url);
|
||||||
|
|
||||||
|
if (selectedSession.factors?.user?.loginName) {
|
||||||
|
signedinUrl.searchParams.set(
|
||||||
|
"loginName",
|
||||||
|
selectedSession.factors?.user?.loginName,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (selectedSession.factors?.user?.organizationId) {
|
||||||
|
signedinUrl.searchParams.set(
|
||||||
|
"organization",
|
||||||
|
selectedSession.factors?.user?.organizationId,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return NextResponse.redirect(signedinUrl);
|
||||||
|
} else {
|
||||||
|
return NextResponse.json({ error }, { status: 500 });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user