Skip to content

Commit

Permalink
chore(debugging): server side logs
Browse files Browse the repository at this point in the history
  • Loading branch information
JaleelB committed Jul 30, 2024
1 parent 1b2d47b commit 3a068c3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion server/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const lucia = new Lucia(adapter, {
};
},
});
console.log("lucia", lucia);

export const validateRequest = async (): Promise<
{ user: User; session: Session } | { user: null; session: null }
Expand All @@ -42,11 +43,13 @@ export const validateRequest = async (): Promise<
}

const result = await lucia.validateSession(sessionId);
console.log("validate session result", result);

// next.js throws when you attempt to set cookie when rendering page
try {
if (result.session && result.session.fresh) {
const sessionCookie = lucia.createSessionCookie(result.session.id);
console.log("session cookie when fresh", sessionCookie);
cookies().set(
sessionCookie.name,
sessionCookie.value,
Expand All @@ -55,13 +58,16 @@ export const validateRequest = async (): Promise<
}
if (!result.session) {
const sessionCookie = lucia.createBlankSessionCookie();
console.log("session cookie when blank", sessionCookie);
cookies().set(
sessionCookie.name,
sessionCookie.value,
sessionCookie.attributes,
);
}
} catch {}
} catch {
console.log("error setting cookie:", result);
}
return result;
};

Expand Down

0 comments on commit 3a068c3

Please sign in to comment.