logout redirects

This commit is contained in:
Max Peintner
2025-06-05 11:01:35 +02:00
parent db3c2d9729
commit 2efb3c6a62
2 changed files with 8 additions and 2 deletions

View File

@@ -27,6 +27,7 @@ export function SessionsClearList({
const router = useRouter(); const router = useRouter();
async function clearHintedSession() { async function clearHintedSession() {
console.log("Clearing session for login hint:", loginHint);
// If a login hint is provided, we logout that specific session // If a login hint is provided, we logout that specific session
const sessionIdToBeCleared = sessions.find((session) => { const sessionIdToBeCleared = sessions.find((session) => {
return session.factors?.user?.loginName === loginHint; return session.factors?.user?.loginName === loginHint;
@@ -35,6 +36,9 @@ export function SessionsClearList({
if (sessionIdToBeCleared) { if (sessionIdToBeCleared) {
const clearSessionResponse = await clearSession({ const clearSessionResponse = await clearSession({
sessionId: sessionIdToBeCleared, sessionId: sessionIdToBeCleared,
}).catch((error) => {
console.error("Error clearing session:", error);
return;
}); });
if (!clearSessionResponse) { if (!clearSessionResponse) {
@@ -58,7 +62,9 @@ export function SessionsClearList({
} }
useEffect(() => { useEffect(() => {
clearHintedSession(); if (loginHint) {
clearHintedSession();
}
}, []); }, []);
return sessions ? ( return sessions ? (

View File

@@ -141,7 +141,7 @@ export async function removeSessionFromCookie<T>({
session: SessionCookie<T>; session: SessionCookie<T>;
cleanup?: boolean; cleanup?: boolean;
sameSite?: boolean | "lax" | "strict" | "none" | undefined; sameSite?: boolean | "lax" | "strict" | "none" | undefined;
}): Promise<any> { }) {
const cookiesList = await cookies(); const cookiesList = await cookies();
const stringifiedCookie = cookiesList.get("sessions"); const stringifiedCookie = cookiesList.get("sessions");