fix: address coderabbit review on #6214

- Remove invalid null return from session callback (must return session object)
- Prevent admin from disabling their own account (guard with isSelf check)
- Hide disable UI when viewing own profile
- Add user existence check to changeDisabled endpoint
- Add OpenAPI metadata to changeDisabled mutation
This commit is contained in:
ajnart committed 2026-07-06 06:31:42 +02:00
1 parent fbac0c8752
commit 39a1a3695e
4 files changed
+35 -12

No files matched your search

+22
View File
@@ -790,7 +790,29 @@ export const userRouter = createTRPCRouter({
}),
)
.output(z.void())
.meta({
openapi: {
method: "PATCH",
path: "/api/users/disabled",
tags: ["users"],
protect: true,
},
})
.mutation(async ({ input, ctx }) => {
const dbUser = await ctx.db.query.users.findFirst({
columns: {
id: true,
},
where: eq(users.id, input.userId),
});
if (!dbUser) {
throw new TRPCError({
code: "NOT_FOUND",
message: "User not found",
});
}
await ctx.db
.update(users)
.set({