Fix login stuff?

This commit is contained in:
Owen Schwartz
2024-10-06 18:43:20 -04:00
parent 06eb1544f4
commit d144704066
11 changed files with 76 additions and 37 deletions

View File

@@ -1,8 +1,17 @@
import api from "@app/api";
import { cookies } from "next/headers";
import lucia from "@server/auth";
export async function verifySession() {
const sessionId = cookies().get(lucia.sessionCookieName)?.value ?? null;
const session = await lucia.validateSession(sessionId || "");
return session;
const sessionId = cookies().get("session")?.value ?? null;
try {
const res = await api.get("/user", {
headers: {
Cookie: `session=${sessionId}`
}
});
return true;
} catch {
return false
}
}