diff --git a/app/controllers/establishment.controller.js b/app/controllers/establishment.controller.js index 95c980f..b8b91e7 100644 --- a/app/controllers/establishment.controller.js +++ b/app/controllers/establishment.controller.js @@ -1155,13 +1155,6 @@ exports.verifyOTPForLogin = async (req, res) => { }); } - if (!user.login_otp) { - return res.status(404).json({ - status: "failed", - message: "Verification code not found or invalid user" - }); - } - // Check OTP expiry if (new Date() > new Date(user.login_otp_expires_at)) { return res.status(400).json({ @@ -1170,6 +1163,13 @@ exports.verifyOTPForLogin = async (req, res) => { }); } + if (!user.login_otp) { + return res.status(404).json({ + status: "failed", + message: "Verification code not found or invalid user" + }); + } + // Verify OTP const isOtpValid = await bcrypt.compare(otp, user.login_otp); if (!isOtpValid) {