deleteUser doesn't delete

When I send a deleteUser thing the user is sent to the api route from better auth just fine and is redirected back to /, but for some reason their account isnt being deleted.

        deleteUser: {
            enabled: true,
            sendDeleteAccountVerification: async ({ user, url }) => {
                await resend.emails.send({
                    from: "Reviseo <onboarding@reviseo.app>",
                    to: [user.email],
                    subject: "Confirm your account deletion",
                    react: DeleteAccountEmail({
                        userName: user.name,
                        userEmail: user.email,
                        verificationUrl: url,
                    }),
                });
            },
        },

        startTransition(async () => {
            try {
                const res = await authClient.deleteUser();

                if (res.error) {
                    toast.error(res.error.message);
                    return;
                }

                if (res.data) {
                    toast.success(
                        "Verification email sent. Please check your inbox to confirm account deletion.",
                    );
                    setOpen(false);
                    setConfirmText("");
                }
            } catch (error) {
                console.error("Error deleting account:", error);
                toast.error("Failed to initiate account deletion. Please try again.");
            }
        });


I'm getting the email just fine and the url looks good, and in the terminal i see a get request working to the /auth/delete-user (or wtv it is)

p.s user is connected to a github account if that helps
Solution

turns out i had to update the schema to have correct onDelete stuff

Was this page helpful?