Change email for unverified user ?
Is there a way to change the email of a user that hasn't been verified ? For exemple this cover the case a user register miss type the email and want to change to his good one.
export const auth = betterAuth({
database: drizzleAdapter(db, {
provider: "pg",
schema: schema,
}),
emailAndPassword: {
enabled: true,
},
emailVerification: {
sendVerificationEmail: async ({ user, url }) => {
await sendEmail({
to: user.email,
subject: "Verify your email address",
text: `Welcome! Please verify your email address by clicking the link below:\n\n${url}\n\nIf you did not sign up, please ignore this email.`,
});
},
},
user: {
changeEmail: {
enabled: true,
// this is skipped if the user is unverified
sendChangeEmailVerification: async ({ user, url }) => {
await sendEmail({
to: user.email,
subject: "Confirm Your Email Change Request",
text: `You have requested to change your email address. Please confirm this request by clicking the link below:\n\n${url}\n\nIf you did not request this change, please ignore this email.`,
});
},
},
},
});authClient.changeEmailauthClient.sendVerificationEmail