mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-16 06:42:06 +00:00
fix client error
This commit is contained in:
@@ -55,9 +55,12 @@ export async function updateSessionCookie(
|
||||
: [session];
|
||||
|
||||
const foundIndex = sessions.findIndex((session) => session.id === id);
|
||||
sessions[foundIndex] = session;
|
||||
|
||||
return setSessionHttpOnlyCookie(sessions);
|
||||
if (foundIndex > -1) {
|
||||
sessions[foundIndex] = session;
|
||||
return setSessionHttpOnlyCookie(sessions);
|
||||
} else {
|
||||
throw "updateSessionCookie: session id now found";
|
||||
}
|
||||
}
|
||||
|
||||
export async function removeSessionFromCookie(
|
||||
@@ -119,11 +122,9 @@ export async function getSessionCookieByLoginName(
|
||||
const cookiesList = cookies();
|
||||
const stringifiedCookie = cookiesList.get("sessions");
|
||||
|
||||
console.log("str", stringifiedCookie);
|
||||
if (stringifiedCookie?.value) {
|
||||
const sessions: SessionCookie[] = JSON.parse(stringifiedCookie?.value);
|
||||
|
||||
console.log("sessions", sessions);
|
||||
const found = sessions.find((s) => s.loginName === loginName);
|
||||
if (found) {
|
||||
return found;
|
||||
|
||||
@@ -86,13 +86,9 @@ export async function setSessionAndUpdateCookie(
|
||||
loginName: session.factors?.user?.loginName ?? "",
|
||||
};
|
||||
|
||||
return updateSessionCookie(sessionCookie.id, newCookie)
|
||||
.then(() => {
|
||||
return session;
|
||||
})
|
||||
.catch((error) => {
|
||||
throw "could not set cookie";
|
||||
});
|
||||
return updateSessionCookie(sessionCookie.id, newCookie).then(() => {
|
||||
return session;
|
||||
});
|
||||
} else {
|
||||
throw "could not get session or session does not have loginName";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user