feat: admin ui for disabling users (#1547)
This commit is contained in:
27
packages/lib/server-only/user/enable-user.ts
Normal file
27
packages/lib/server-only/user/enable-user.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { AppError } from '@documenso/lib/errors/app-error';
|
||||
import { prisma } from '@documenso/prisma';
|
||||
|
||||
export type EnableUserOptions = {
|
||||
id: number;
|
||||
};
|
||||
|
||||
export const enableUser = async ({ id }: EnableUserOptions) => {
|
||||
const user = await prisma.user.findFirst({
|
||||
where: {
|
||||
id,
|
||||
},
|
||||
});
|
||||
|
||||
if (!user) {
|
||||
throw new AppError('There was an error enabling the user');
|
||||
}
|
||||
|
||||
await prisma.user.update({
|
||||
where: {
|
||||
id,
|
||||
},
|
||||
data: {
|
||||
disabled: false,
|
||||
},
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user