feat: new "safe" procedure without unauth throwing
This commit is contained in:
@@ -10,7 +10,7 @@ import { unauthorizedError } from "./errors/trpc"
|
||||
typeof auth
|
||||
|
||||
type CreateContextOptions = {
|
||||
auth: () => Promise<Session>
|
||||
auth: () => Promise<Session | null>
|
||||
lang: Lang
|
||||
pathname: string
|
||||
uid?: string | null
|
||||
@@ -50,7 +50,7 @@ export function createContext() {
|
||||
const session = await auth()
|
||||
const webToken = webviewTokenCookie?.value
|
||||
if (!session?.token && !webToken) {
|
||||
throw unauthorizedError()
|
||||
return null
|
||||
}
|
||||
|
||||
return session || ({ token: { access_token: webToken } } as Session)
|
||||
|
||||
Reference in New Issue
Block a user