trpc: check unlimited in middleware
This commit is contained in:
parent
1ea11f8eff
commit
90c0ef481b
@ -25,9 +25,17 @@ export const userMiddleware = t.middleware(async ({ ctx, next }) => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const unlimited = systemuser?.roles?.some((x) => x?.name && unlimitedRoles.includes(x.name));
|
||||||
|
|
||||||
|
if (!unlimited) {
|
||||||
|
throw new TRPCError({
|
||||||
|
code: 'UNAUTHORIZED',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return next({
|
return next({
|
||||||
ctx: {
|
ctx: {
|
||||||
unlimited: systemuser?.roles?.some((x) => x?.name && unlimitedRoles.includes(x.name)),
|
unlimited,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user