This commit is contained in:
1 parent
de1b3754df
commit
f085517732
3 files changed
+45
-18
No files matched your search
+11
-15
@@ -12,10 +12,7 @@ export const auth = betterAuth({
|
||||
emailOTP({
|
||||
async sendVerificationOTP({ email, otp, type }) {
|
||||
if (type === 'sign-in') {
|
||||
// Send the OTP for sign in
|
||||
console.log({ email, otp, type });
|
||||
|
||||
void EmailSender.getTransporter().sendMail({
|
||||
EmailSender.sendInBackground({
|
||||
to: email,
|
||||
subject: `Your OTP code is: ${otp}`,
|
||||
text: `Your OTP code is: ${otp}`,
|
||||
@@ -23,8 +20,13 @@ export const auth = betterAuth({
|
||||
} else if (type === 'email-verification') {
|
||||
// Send the OTP for email verification
|
||||
console.log({ email, otp, type });
|
||||
} else if (type === 'forget-password') {
|
||||
EmailSender.sendInBackground({
|
||||
to: email,
|
||||
subject: `Your password reset code is: ${otp}`,
|
||||
text: `Your password reset code is: ${otp}`,
|
||||
});
|
||||
} else {
|
||||
// Send the OTP for password reset
|
||||
console.log({ email, otp, type });
|
||||
}
|
||||
},
|
||||
@@ -47,26 +49,21 @@ export const auth = betterAuth({
|
||||
autoSignIn: false,
|
||||
requireEmailVerification: true,
|
||||
onExistingUserSignUp: async ({ user }, request) => {
|
||||
console.log('onExistingUserSignUp', { user });
|
||||
|
||||
void EmailSender.getTransporter().sendMail({
|
||||
EmailSender.sendInBackground({
|
||||
to: user.email,
|
||||
subject: 'Sign-up attempt with your email',
|
||||
text: 'Someone tried to create an account using your email address. If this was you, try signing in instead. If not, you can safely ignore this email.',
|
||||
});
|
||||
},
|
||||
sendResetPassword: async ({ user, url, token }, request) => {
|
||||
console.log('sendResetPassword', { user, url, token });
|
||||
void EmailSender.getTransporter().sendMail({
|
||||
EmailSender.sendInBackground({
|
||||
to: user.email,
|
||||
subject: 'Reset your password',
|
||||
text: `Click the link to reset your password: ${url}`,
|
||||
});
|
||||
},
|
||||
onPasswordReset: async ({ user }, request) => {
|
||||
// your logic here
|
||||
console.log('onPasswordReset', { user });
|
||||
void EmailSender.getTransporter().sendMail({
|
||||
EmailSender.sendInBackground({
|
||||
to: user.email,
|
||||
subject: 'Reset your password result',
|
||||
text: `Password for user ${user.email} has been reset.`,
|
||||
@@ -77,8 +74,7 @@ export const auth = betterAuth({
|
||||
sendOnSignIn: true,
|
||||
autoSignInAfterVerification: true,
|
||||
sendVerificationEmail: async ({ user, url }) => {
|
||||
console.log('emailVerification', { user, url });
|
||||
void EmailSender.getTransporter().sendMail({
|
||||
EmailSender.sendInBackground({
|
||||
to: user.email,
|
||||
subject: 'Verify your email address',
|
||||
text: `Click the link to verify your email: ${url}`,
|
||||
|
||||
Reference in new issue
Block a user