diff --git a/app/controllers/establishment.controller.js b/app/controllers/establishment.controller.js index a82dd37..ccf4424 100644 --- a/app/controllers/establishment.controller.js +++ b/app/controllers/establishment.controller.js @@ -763,6 +763,13 @@ exports.forgotPasswordRequestOTP = async (req, res) => { reset_otp_expires_at: new Date(Date.now() + 10 * 60 * 1000), // valid for 10 mins }); + // Send OTP email + await sendEmail( + registered_email, + "Password Reset OTP", + `
Dear ${user.name},
Your OTP for password reset is ${otp}. It is valid for 10 minutes.
` + ); + }else{ const adminUser = await user.findOne({where: { email: registered_email },}); @@ -782,19 +789,20 @@ exports.forgotPasswordRequestOTP = async (req, res) => { reset_otp_expires_at: new Date(Date.now() + 10 * 60 * 1000), // valid for 10 mins }); + // Send OTP email + await sendEmail( + registered_email, + "Password Reset OTP", + `Dear ${adminUser.name},
Your OTP for password reset is ${otp}. It is valid for 10 minutes.
` + ); + } - // Send OTP email - await sendEmail( - registered_email, - "Password Reset OTP", - `Dear ${user.name},
Your OTP for password reset is ${otp}. It is valid for 10 minutes.
` - ); - logger.info(`OTP sent to ${registered_email} for establishment_id=${establishment.id}`); + logger.info(`OTP sent to ${registered_email}`); return res.status(200).json({ status: "success", @@ -868,8 +876,6 @@ exports.forgotPasswordVerifyOTP = async (req, res) => { } - - logger.info(`Password reset successful for user=${registered_email}`); return res.status(200).json({