mirror of
https://github.com/codeflash-ai/codeflash-internal.git
synced 2026-05-04 18:25:18 +00:00
fix: redirect remaining auth throws that crash prerendering
getUserIdAndUsername() and getAccountContext() also threw generic errors when no session exists. Same fix as apikeys: use redirect() which Next.js handles as a prerender bailout signal.
This commit is contained in:
parent
09ed4d4b44
commit
71127055f3
2 changed files with 3 additions and 2 deletions
|
|
@ -18,7 +18,7 @@ export async function getUserIdAndUsername(): Promise<{ username: string; userId
|
|||
const session = await getCachedSession()
|
||||
|
||||
if (!session?.user?.sub || !session?.user?.nickname) {
|
||||
throw new Error("User session not found or incomplete")
|
||||
redirect("/login")
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { cache } from "react"
|
||||
import { cookies } from "next/headers"
|
||||
import { redirect } from "next/navigation"
|
||||
import { auth0 } from "@/lib/auth0"
|
||||
import { getUserOrganizations } from "@/components/dashboard/action"
|
||||
import type { AccountPayload } from "@codeflash-ai/common"
|
||||
|
|
@ -13,7 +14,7 @@ export const getAccountContext = cache(async (): Promise<AccountPayload> => {
|
|||
const session = await auth0.getSession()
|
||||
|
||||
if (!session?.user?.sub || !session?.user?.nickname) {
|
||||
throw new Error("User session not found or incomplete")
|
||||
redirect("/login")
|
||||
}
|
||||
|
||||
const cookieStore = await cookies()
|
||||
|
|
|
|||
Loading…
Reference in a new issue