feat(audit-logging): Replace req.session with req.auth for audit logging in notes and projects
This commit is contained in:
37
test-auth-session.mjs
Normal file
37
test-auth-session.mjs
Normal file
@@ -0,0 +1,37 @@
|
||||
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();
|
||||
Reference in New Issue
Block a user