fix: refactor session handling

This commit is contained in:
Christel Westerberg
2024-05-28 14:41:05 +02:00
parent cd3c5491ec
commit 07f81c34e3
7 changed files with 34 additions and 36 deletions

View File

@@ -41,13 +41,9 @@ export const protectedProcedure = t.procedure.use(async function (opts) {
throw sessionExpiredError()
}
if (!session?.token.access_token && !opts.ctx.webToken) {
throw unauthorizedError()
}
return opts.next({
ctx: {
session: session || { token: { access_token: opts.ctx.webToken } },
session,
},
})
})