mirror of
https://github.com/lukevella/rallly.git
synced 2025-05-12 00:17:03 +02:00
⬆️ v3.0.0 (#704)
This commit is contained in:
parent
735056f25f
commit
c22b3abc4d
385 changed files with 19912 additions and 5250 deletions
|
@ -16,13 +16,28 @@ export const publicProcedure = t.procedure;
|
|||
|
||||
export const middleware = t.middleware;
|
||||
|
||||
const checkAuthIfRequired = middleware(async ({ ctx, next }) => {
|
||||
if (process.env.AUTH_REQUIRED === "true" && ctx.user.isGuest) {
|
||||
throw new TRPCError({ code: "UNAUTHORIZED", message: "Login is required" });
|
||||
}
|
||||
return next();
|
||||
});
|
||||
export const possiblyPublicProcedure = t.procedure.use(
|
||||
middleware(async ({ ctx, next }) => {
|
||||
if (process.env.AUTH_REQUIRED === "true" && ctx.user.isGuest) {
|
||||
throw new TRPCError({
|
||||
code: "UNAUTHORIZED",
|
||||
message: "Login is required",
|
||||
});
|
||||
}
|
||||
return next();
|
||||
}),
|
||||
);
|
||||
|
||||
export const possiblyPublicProcedure = t.procedure.use(checkAuthIfRequired);
|
||||
export const privateProcedure = t.procedure.use(
|
||||
middleware(async ({ ctx, next }) => {
|
||||
if (ctx.user.isGuest) {
|
||||
throw new TRPCError({
|
||||
code: "UNAUTHORIZED",
|
||||
message: "Login is required",
|
||||
});
|
||||
}
|
||||
return next();
|
||||
}),
|
||||
);
|
||||
|
||||
export const mergeRouters = t.mergeRouters;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue