feat: Improve session validation and logging in PhotosPage
- Added additional logging to track session and user details, enhancing debugging capabilities. - Implemented checks for both session existence and user presence, redirecting to the login page as necessary. - Improved session information output for better context during page rendering.
This commit is contained in:
parent
f2efa772d6
commit
a465e39a4d
@ -9,19 +9,28 @@ import DeletePhotoButton from "@/components/DeletePhotoButton"
|
|||||||
export const revalidate = 60 // Revalidate every 60 seconds
|
export const revalidate = 60 // Revalidate every 60 seconds
|
||||||
|
|
||||||
export default async function PhotosPage() {
|
export default async function PhotosPage() {
|
||||||
|
console.log("PhotosPage: Starting, calling auth()...")
|
||||||
const session = await auth()
|
const session = await auth()
|
||||||
|
|
||||||
console.log("PhotosPage: auth() returned", {
|
console.log("PhotosPage: auth() returned", {
|
||||||
hasSession: !!session,
|
hasSession: !!session,
|
||||||
sessionType: typeof session,
|
sessionType: typeof session,
|
||||||
sessionUser: session?.user,
|
sessionUser: session?.user,
|
||||||
sessionKeys: session ? Object.keys(session) : []
|
sessionKeys: session ? Object.keys(session) : [],
|
||||||
|
sessionString: JSON.stringify(session, null, 2)
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!session) {
|
if (!session) {
|
||||||
console.log("PhotosPage: No session, redirecting to login")
|
console.log("PhotosPage: No session, redirecting to login")
|
||||||
redirect("/login")
|
redirect("/login")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!session.user) {
|
||||||
|
console.log("PhotosPage: Session exists but no user, redirecting to login")
|
||||||
|
redirect("/login")
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("PhotosPage: Session valid, rendering page")
|
||||||
|
|
||||||
// Limit to 50 photos per page for performance
|
// Limit to 50 photos per page for performance
|
||||||
const photos = await prisma.photo.findMany({
|
const photos = await prisma.photo.findMany({
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user