Files
sign/packages/lib/server-only/user/delete-user.ts

22 lines
382 B
TypeScript
Raw Normal View History

2023-10-05 11:38:51 +03:00
import { prisma } from '@documenso/prisma';
2023-10-12 12:19:23 +03:00
export const deleteUser = async (email: string) => {
2023-10-05 11:38:51 +03:00
const user = await prisma.user.findFirst({
where: {
2023-10-12 12:19:23 +03:00
email: {
contains: email,
2023-10-05 11:38:51 +03:00
},
},
});
if (!user) {
2023-10-12 12:19:23 +03:00
throw new Error(`User with email ${email} not found`);
2023-10-05 11:38:51 +03:00
}
return await prisma.user.delete({
where: {
id: user.id,
},
});
};