Files
micro-service-api/exthernal-login-api/src/controllers/otpController/otpVerifycontroller.js
2025-11-11 12:36:06 +07:00

25 lines
859 B
JavaScript

import { sendError } from '../../utils/response.js';
import { OTPVerifyService } from '../../services/otpverifyservice.js';
import { GeneralService } from '../../share/generalservice.js';
export class OtpVerifyController {
constructor() {
this.otpVerifyService = new OTPVerifyService();
this.generalService = new GeneralService();
}
async onNavigate(req, res) {
let idx = -1, result = [];
try {
const { email, otp } = req.body.request;
result = await this.otpVerifyService.verifyOtp(email, otp);
} catch (error) {
idx = 1;
this.generalService.devhint(1, 'otpverifycontroller.js', 'Jumpout', error.message);
} finally {
if (idx === 1) return sendError('เกิดข้อผิดพลาดในการตรวจสอบ OTP', 'OTP verification error');
return result;
}
}
}