Skip to content

Commit 75d7132

Browse files
committed
[offers][fix] add check if admin for list endpoint
1 parent 55beb38 commit 75d7132

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

apps/portal/src/server/router/offers/offers-admin-router.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,20 @@ export const offerAdminRouter = createProtectedRouter().query('list', {
6464
yoeMin: z.number().min(0).nullish(),
6565
}),
6666
async resolve({ ctx, input }) {
67+
const userId = ctx.session.user.id;
68+
const adminAccount = await ctx.prisma.offersAdmin.findFirst({
69+
where: {
70+
userId
71+
}
72+
})
73+
74+
if (!adminAccount) {
75+
throw new TRPCError({
76+
code: 'UNAUTHORIZED',
77+
message: 'Not an admin.',
78+
});
79+
}
80+
6781
const yoeRange = getYoeRange(input.yoeCategory);
6882
const yoeMin = input.yoeMin != null ? input.yoeMin : yoeRange?.minYoe;
6983
const yoeMax = input.yoeMax != null ? input.yoeMax : yoeRange?.maxYoe;

0 commit comments

Comments
 (0)