mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 08:13:56 +10:00
chore: update pr based on review
This commit is contained in:
@ -124,9 +124,7 @@ export const ProfileForm = ({ className, user }: ProfileFormProps) => {
|
|||||||
duration: 5000,
|
duration: 5000,
|
||||||
});
|
});
|
||||||
|
|
||||||
await signOut({ callbackUrl: '/' });
|
return await signOut({ callbackUrl: '/' });
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const { token } = deleteAccountTwoFactorTokenForm.getValues();
|
const { token } = deleteAccountTwoFactorTokenForm.getValues();
|
||||||
|
|||||||
@ -1,10 +0,0 @@
|
|||||||
import { stripe } from '@documenso/lib/server-only/stripe';
|
|
||||||
import type { User } from '@documenso/prisma/client';
|
|
||||||
|
|
||||||
export const deleteStripeCustomer = async (user: User) => {
|
|
||||||
if (!user.customerId) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return await stripe.customers.del(user.customerId);
|
|
||||||
};
|
|
||||||
@ -4,7 +4,7 @@ export type DeleteUserOptions = {
|
|||||||
email: string;
|
email: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const deleteUser = async ({ email }: DeleteUserOptions) => {
|
export const deletedServiceAccount = async ({ email }: DeleteUserOptions) => {
|
||||||
const user = await prisma.user.findFirst({
|
const user = await prisma.user.findFirst({
|
||||||
where: {
|
where: {
|
||||||
email: {
|
email: {
|
||||||
|
|||||||
@ -26,9 +26,3 @@ export const ZSignUpMutationSchema = z.object({
|
|||||||
export type TSignUpMutationSchema = z.infer<typeof ZSignUpMutationSchema>;
|
export type TSignUpMutationSchema = z.infer<typeof ZSignUpMutationSchema>;
|
||||||
|
|
||||||
export const ZVerifyPasswordMutationSchema = ZSignUpMutationSchema.pick({ password: true });
|
export const ZVerifyPasswordMutationSchema = ZSignUpMutationSchema.pick({ password: true });
|
||||||
|
|
||||||
export const ZDeleteAccountMutationSchema = z.object({
|
|
||||||
email: z.string().email(),
|
|
||||||
});
|
|
||||||
|
|
||||||
export type TDeleteAccountMutationSchema = z.infer<typeof ZDeleteAccountMutationSchema>;
|
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
import { TRPCError } from '@trpc/server';
|
import { TRPCError } from '@trpc/server';
|
||||||
|
|
||||||
import { deleteStripeCustomer } from '@documenso/ee/server-only/stripe/delete-customer';
|
import { deletedServiceAccount } from '@documenso/lib/server-only/user/delete-user';
|
||||||
import { deleteUser } from '@documenso/lib/server-only/user/delete-user';
|
|
||||||
import { findUserSecurityAuditLogs } from '@documenso/lib/server-only/user/find-user-security-audit-logs';
|
import { findUserSecurityAuditLogs } from '@documenso/lib/server-only/user/find-user-security-audit-logs';
|
||||||
import { forgotPassword } from '@documenso/lib/server-only/user/forgot-password';
|
import { forgotPassword } from '@documenso/lib/server-only/user/forgot-password';
|
||||||
import { getUserById } from '@documenso/lib/server-only/user/get-user-by-id';
|
import { getUserById } from '@documenso/lib/server-only/user/get-user-by-id';
|
||||||
@ -161,9 +160,8 @@ export const profileRouter = router({
|
|||||||
deleteAccount: authenticatedProcedure.mutation(async ({ ctx }) => {
|
deleteAccount: authenticatedProcedure.mutation(async ({ ctx }) => {
|
||||||
try {
|
try {
|
||||||
const user = ctx.user;
|
const user = ctx.user;
|
||||||
await deleteStripeCustomer(user);
|
|
||||||
|
|
||||||
return await deleteUser(user);
|
return await deletedServiceAccount(user);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
let message = 'We were unable to delete your account. Please try again.';
|
let message = 'We were unable to delete your account. Please try again.';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user