fix: session validation fixes

This commit is contained in:
2026-01-11 11:23:32 -05:00
parent 842a6075f9
commit 1fb8f45705
5 changed files with 166 additions and 37 deletions

View File

@@ -185,19 +185,22 @@ export async function getAuthSession(
// In SSR contexts where headers may already be sent, use unsealSession directly
if (skipUpdate) {
const { unsealSession } = await import("vinxi/http");
const cookieValue = getCookie(event, sessionConfig.cookieName);
const cookieName = sessionConfig.name || "session";
const cookieValue = getCookie(event, cookieName);
if (!cookieValue) {
return null;
}
try {
const data = await unsealSession<SessionData>(
event,
sessionConfig,
cookieValue
);
// unsealSession returns Partial<Session<T>>, not T directly
const session = await unsealSession(event, sessionConfig, cookieValue);
if (!data || !data.userId || !data.sessionId) {
if (!session?.data || typeof session.data !== "object") {
return null;
}
const data = session.data as SessionData;
if (!data.userId || !data.sessionId) {
return null;
}