|
|
@ -39,12 +39,14 @@ export const publicProcedure = t.procedure;
|
|
|
|
export const authProcedure = publicProcedure.use(
|
|
|
|
export const authProcedure = publicProcedure.use(
|
|
|
|
async ({ ctx: { jwt }, next }) => {
|
|
|
|
async ({ ctx: { jwt }, next }) => {
|
|
|
|
if (!jwt) {
|
|
|
|
if (!jwt) {
|
|
|
|
throw new TRPCError({ code: "UNAUTHORIZED" });
|
|
|
|
throw new TRPCError({
|
|
|
|
|
|
|
|
code: "UNAUTHORIZED",
|
|
|
|
|
|
|
|
message: JSON.stringify(jwt),
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!jwt.id) {
|
|
|
|
if (!jwt.id) {
|
|
|
|
throw new TRPCError({ code: "UNAUTHORIZED" });
|
|
|
|
throw new TRPCError({ code: "UNAUTHORIZED" });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
jwt.email;
|
|
|
|
|
|
|
|
return await next({
|
|
|
|
return await next({
|
|
|
|
ctx: { jwt },
|
|
|
|
ctx: { jwt },
|
|
|
|
});
|
|
|
|
});
|
|
|
|