Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion apps/blade/src/app/admin/forms/[slug]/client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,13 @@
allowEdit,
responseRoleIds,
});
}, [

Check warning on line 252 in apps/blade/src/app/admin/forms/[slug]/client.tsx

View workflow job for this annotation

GitHub Actions / lint

React Hook React.useCallback has a missing dependency: 'updateFormMutation'. Either include it or remove the dependency array
isLoading,
isFetching,
formTitle,
formData,
slug,
questions,
updateFormMutation,
formDescription,
formBanner,
instructions,
Expand Down
20 changes: 12 additions & 8 deletions packages/api/src/routers/misc.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { TRPCRouterRecord } from "@trpc/server";
import { TRPCError } from "@trpc/server";
import { Routes } from "discord-api-types/v10";
import { z } from "zod";

Expand Down Expand Up @@ -84,10 +85,11 @@ export const miscRouter = {
}),
)
.mutation(async ({ input, ctx }) => {
if (FORMS.ALLOWED_ASSIGNABLE_DISCORD_ROLES.includes(input.roleId)) {
throw new Error(
`Roleid: ${input.roleId} is not assignable through forms for security purposes. Add to consts and make a PR if this is a mistake.`,
);
if (!FORMS.ALLOWED_ASSIGNABLE_DISCORD_ROLES.includes(input.roleId)) {
throw new TRPCError({
message: `Roleid: ${input.roleId} is not assignable through forms for security purposes. Add to consts and make a PR if this is a mistake.`,
code: "INTERNAL_SERVER_ERROR",
});
}

try {
Expand All @@ -99,10 +101,12 @@ export const miscRouter = {
input.roleId,
),
);
} catch {
throw new Error(
`Could not assign role ${input.roleId} to user ${ctx.session.user.name}`,
);
} catch (err) {
throw new TRPCError({
message: `Could not assign role ${input.roleId} to user ${ctx.session.user.name}`,
cause: err,
code: "INTERNAL_SERVER_ERROR",
});
}
}),

Expand Down