added 2FA
This commit is contained in:
@@ -2,11 +2,32 @@
|
||||
|
||||
import mailer from '@/lib/mailer'
|
||||
import { AUTH_NEW_PASSWORD_URL, AUTH_USER_VERIFICATION_URL } from '@/config/routes'
|
||||
import { generatePasswordResetToken, generateVerificationToken } from '@/lib/tokens'
|
||||
import { generatePasswordResetToken, generateTwoFactorToken, generateVerificationToken } from '@/lib/tokens'
|
||||
import { env } from '@/lib/utils'
|
||||
import { __ct } from '@/lib/translate'
|
||||
import { body } from '@/templates/email/send-verification-email'
|
||||
|
||||
export const sendTwoFactorTokenEmail = async (email: string, token: string, name?: string | null) => {
|
||||
const { isOk, code, info, error } = await mailer({
|
||||
to: name ? { name: name?.toString(), address: email } : email,
|
||||
subject: await __ct({
|
||||
key: 'mailer.subject.send_2FA_code',
|
||||
params: { site_name: env('SITE_NAME') },
|
||||
}),
|
||||
text: `Your 2FA code: ${token}`,
|
||||
html: `<p>Your 2FA code: ${token}</p>`,
|
||||
})
|
||||
|
||||
return isOk
|
||||
// TODO: Log this action
|
||||
// if (isOk && code === 250) {
|
||||
// //return //'auth.email.success._2FA_email_sent'
|
||||
// return { success: code === 250 ? 'auth.email.success._2FA_email_sent' : info?.response }
|
||||
// } else {
|
||||
// return { error: env('DEBUG') === 'true' ? error?.response : 'auth.email.error._2FA_email_sending_error' }
|
||||
// }
|
||||
}
|
||||
|
||||
const sendVerificationEmail = async (
|
||||
email: string,
|
||||
name?: string | null,
|
||||
|
||||
Reference in New Issue
Block a user