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

25 lines
915 B
JavaScript

import { ResetPasswordService } from '../../services/resetpasswordservice.js';
import { sendError } from '../../utils/response.js';
import { GeneralService } from '../../share/generalservice.js';
export class ResetPasswordController {
constructor() {
this.resetPasswordService = new ResetPasswordService();
this.generalService = new GeneralService();
}
async onNavigate(req, res) {
let idx = -1, result = [];
try {
const { email, token, newPassword } = req.body.request;
result = await this.resetPasswordService.resetPassword(email, token, newPassword);
} catch (error) {
idx = 1;
this.generalService.devhint(1, 'resetpasswordcontroller.js', 'Jumpout', error.message);
} finally {
if (idx === 1) return sendError('ไม่สามารถรีเซ็ตรหัสผ่านได้', 'Password reset error');
return result;
}
}
}