From f9f134fc4c41e8f6430d6bc4c0b207c55641f828 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Wed, 14 May 2025 12:40:35 +0530 Subject: [PATCH] FIX_OTP_ISSUE : RV --- .../RestAuthenticationController.php | 34 ++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php index a4a98d5..7f2f9f4 100755 --- a/app/Controllers/RestAuthenticationController.php +++ b/app/Controllers/RestAuthenticationController.php @@ -138,9 +138,24 @@ class RestAuthenticationController extends AdminController $otp = random_int(100000, 999999); - $update = $this->employeeModel->where('email_corporate', $email)->where('relationship', 'self') - ->where('is_active', 1)->set(array('otp' => $otp )) - ->update(); + // $update = $this->employeeModel->where('email_corporate', $email)->where('relationship', 'self') + // ->where('is_active', 1)->set(array('otp' => $otp )) + // ->update(); + + $sql = " + UPDATE employees + INNER JOIN employee_polices ON employee_polices.employee_id = employees.id + SET employees.otp = ? + WHERE employees.email_corporate = ? + AND employees.relationship = 'self' + AND employees.is_active = 1 + AND employee_polices.is_active = 1 + AND employee_polices.status IN ('draft', 'enrolled') + "; + + $db = db_connect(); + $update = $db->query($sql, [$otp, $email]); + if($update) { @@ -198,7 +213,18 @@ class RestAuthenticationController extends AdminController }else{ if (isset($mobile_number)) { - $employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->where('emp_status !=', 'truncated')->where('is_active', 1)->first(); + // $employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->where('emp_status !=', 'truncated')->where('is_active', 1)->first(); + + $employeeData = $this->employeeModel + ->select('employees.*') + ->join('employee_polices EP', 'EP.employee_id = employees.id', 'inner') + ->where('employees.is_active', 1) + ->where('employees.relationship', 'self') + ->where('employees.emp_status !=', 'truncated') + ->where('employees.mobile', $mobile_number) + ->where('EP.is_active', 1) + ->whereIn('EP.status', ['draft', 'enrolled']) + ->first(); } else { $employeeData = $this->employeeModel->where('email_corporate', $email_id)->where('otp', $otp)->where('relationship', 'self')->where('emp_status !=', 'truncated')->where('is_active', 1)->first(); }