debug: log out cause for user

This commit is contained in:
Christel Westerberg
2024-08-26 15:26:58 +02:00
parent f8d60afb49
commit e04485d896

View File

@@ -28,8 +28,37 @@ export default async function ProtectedLayout({
}
const user = await serverClient().user.get()
if (!user || "error" in user) {
console.log(`[layout:protected] no user, redirecting to: ${redirectURL}`)
if (user && "error" in user) {
// redirect(redirectURL)
console.error("[layout:protected] error in user", user)
console.error(
"[layout:protected] full user: ",
JSON.stringify(user, null, 4)
)
switch (user.cause) {
case "unauthorized": // fall through
case "forbidden": // fall through
case "token_expired":
console.error(
`[layout:protected] user error, redirecting to: ${redirectURL}`
)
redirect(redirectURL)
case "notfound":
console.error(`[layout:protected] notfound user loading error`)
case "unknown":
console.error(`[layout:protected] unknown user loading error`)
default:
console.error(`[layout:protected] unhandled user loading error`)
}
return <p>Something went wrong!</p>
}
if (!user) {
console.error(
"[layout:protected] no user found, redirecting to: ",
redirectURL
)
redirect(redirectURL)
}