fix: improve auth handling and logging
This commit is contained in:
@@ -20,13 +20,17 @@ export default async function ProtectedLayout({
|
||||
h.get("x-url") ?? h.get("x-pathname") ?? overview[getLang()]
|
||||
)
|
||||
|
||||
const redirectURL = `/${getLang()}/login?redirectTo=${redirectTo}`
|
||||
|
||||
if (!session) {
|
||||
redirect(`/${getLang()}/login?redirectTo=${redirectTo}`)
|
||||
console.log(`[layout:protected] no session, redirecting to: ${redirectURL}`)
|
||||
redirect(redirectURL)
|
||||
}
|
||||
|
||||
const user = await serverClient().user.get()
|
||||
if (!user || "error" in user) {
|
||||
redirect(`/${getLang()}/login?redirectTo=${redirectTo}`)
|
||||
console.log(`[layout:protected] no user, redirecting to: ${redirectURL}`)
|
||||
redirect(redirectURL)
|
||||
}
|
||||
|
||||
return children
|
||||
|
||||
Reference in New Issue
Block a user