feat(WEB-215): add refresh_token
This commit is contained in:
committed by
Michael Zetterberg
parent
68f1e87169
commit
c4912bbb94
@@ -39,3 +39,13 @@ export function internalServerError(cause?: unknown) {
|
||||
cause,
|
||||
})
|
||||
}
|
||||
|
||||
export const SESSION_EXPIRED = "SESSION_EXPIRED"
|
||||
export class SessionExpiredError extends Error {}
|
||||
export function sessionExpiredError() {
|
||||
return new TRPCError({
|
||||
code: "UNAUTHORIZED",
|
||||
message: SESSION_EXPIRED,
|
||||
cause: new SessionExpiredError(SESSION_EXPIRED),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -34,6 +34,10 @@ export const protectedProcedure = t.procedure.use(async function (opts) {
|
||||
console.info(`path: ${opts.path} | type: ${opts.type}`)
|
||||
}
|
||||
|
||||
if (session?.error === "RefreshAccessTokenError") {
|
||||
throw unauthorizedError()
|
||||
}
|
||||
|
||||
if (!session?.user) {
|
||||
throw unauthorizedError()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user