Files
micro-service-api/exthernal-accountingwep-api/src/services/otpservice.js
2025-11-11 15:11:56 +07:00

18 lines
540 B
JavaScript

import { generateOTP } from '../utils/otp.js'
import { sendMockOtpMail } from '../utils/mailer.js'
import { saveOtp, verifyOtp, removeOtp } from '../utils/redis.js'
import { sendError } from '../utils/response.js'
export class OtpService {
async sendOtp(email) {
try {
const otp = generateOTP()
await saveOtp(email, otp)
await sendMockOtpMail(email, otp)
return { email, otp}
} catch (error) {
return sendError('ไม่สามารถส่ง OTP ได้', 'Failed to send OTP')
}
}
}