let them reauthenticate with a bad session

This commit is contained in:
Max Peintner
2024-12-09 14:57:39 +01:00
parent 40b474821f
commit a749c76f4f

View File

@@ -170,7 +170,22 @@ export async function GET(request: NextRequest) {
const isValid = await isSessionValid(selectedSession);
if (isValid) {
if (!isValid && selectedSession.factors?.user) {
// if the session is not valid anymore, we need to redirect the user to re-authenticate
const command: SendLoginnameCommand = {
loginName: selectedSession.factors.user?.loginName,
organization: selectedSession.factors?.user?.organizationId,
authRequestId: authRequestId,
};
const res = await sendLoginname(command);
if (res?.redirect) {
const absoluteUrl = new URL(res.redirect, request.url);
return NextResponse.redirect(absoluteUrl.toString());
}
}
const cookie = sessionCookies.find(
(cookie) => cookie.id === selectedSession?.id,
);
@@ -239,7 +254,6 @@ export async function GET(request: NextRequest) {
}
}
}
}
if (authRequestId) {
const { authRequest } = await getAuthRequest({ authRequestId });