(ctx: TRPCContext)
| 111 | }; |
| 112 | |
| 113 | export const requireIsAdmin = async (ctx: TRPCContext) => { |
| 114 | ctx.markAccessControlRun(); |
| 115 | |
| 116 | const userId = requireUserId(ctx); |
| 117 | |
| 118 | if (!(await isAdmin(userId))) { |
| 119 | throw new TRPCError({ |
| 120 | code: "UNAUTHORIZED", |
| 121 | message: "You must be an admin to perform this action.", |
| 122 | }); |
| 123 | } |
| 124 | }; |
| 125 | |
| 126 | export const accessChecks = { |
| 127 | requireNothing, |
no test coverage detected