Files
panel/test-auth-session.mjs

38 lines
1.1 KiB
JavaScript

import { auth } from "@/lib/auth";
// Test what the auth session looks like
console.log("Testing authentication session structure...\n");
async function testAuth() {
try {
// Create a mock request
const mockReq = {
url: "http://localhost:3000/api/projects",
method: "GET",
headers: new Map([
["cookie", ""], // Add any cookies if needed
]),
};
// This is how the auth middleware would wrap a handler
const testHandler = auth(async (req) => {
console.log("=== Authentication Session Debug ===");
console.log("req.auth:", JSON.stringify(req.auth, null, 2));
console.log("req.auth?.user:", JSON.stringify(req.auth?.user, null, 2));
console.log("req.auth?.user?.id:", req.auth?.user?.id);
console.log("req.user:", JSON.stringify(req.user, null, 2));
console.log("req.user?.id:", req.user?.id);
return { success: true };
});
// This would normally be called by Next.js
const result = await testHandler(mockReq);
console.log("Handler result:", result);
} catch (error) {
console.error("Auth test failed:", error);
}
}
testAuth();