Files
sign/packages/trpc/server/admin-router/router.ts

24 lines
711 B
TypeScript
Raw Normal View History

2023-09-29 17:26:37 +01:00
import { TRPCError } from '@trpc/server';
import { updateUser } from '@documenso/lib/server-only/admin/update-user';
2023-10-11 12:32:33 +03:00
import { adminProcedure, router } from '../trpc';
2023-09-29 17:26:37 +01:00
import { ZUpdateProfileMutationByAdminSchema } from './schema';
export const adminRouter = router({
2023-10-11 12:32:33 +03:00
updateUser: adminProcedure
2023-09-29 17:26:37 +01:00
.input(ZUpdateProfileMutationByAdminSchema)
2023-10-11 12:32:33 +03:00
.mutation(async ({ input }) => {
2023-09-29 17:26:37 +01:00
const { id, name, email, roles } = input;
try {
return await updateUser({ id, name, email, roles });
} catch (err) {
throw new TRPCError({
code: 'BAD_REQUEST',
message: 'We were unable to retrieve the specified account. Please try again.',
});
}
}),
});