CHANGE : active policy check in login api

This commit is contained in:
Gowtham M 2025-02-27 15:27:48 +05:30
parent 913a8b6574
commit e589580b48

View File

@ -83,24 +83,26 @@ class RestAuthenticationController extends AdminController
$mobile_number = $this->request->getJSON()->mobile_number; $mobile_number = $this->request->getJSON()->mobile_number;
$employeeData = $this->employeeModel->where('mobile', $mobile_number) $employeeData = $this->employeeModel->select('employees.relationship,EP.employee_id')
->where('relationship', 'self') ->join('employee_polices EP', 'EP.employee_id = employees.id', 'inner')
->where('emp_status !=', 'truncated') ->where('employees.is_active', 1)
->where('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(); ->first();
if ($employeeData) {
if (isset($employeeData['employee_id']))
{
$result = ['user_verification' => true ,'message' => "Verified Successfully" ]; $result = ['user_verification' => true ,'message' => "Verified Successfully" ];
return $this->respond(['status' => 'success','code' => 200,'data' => $result],200); return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
} else { } else {
// Call the third-party API function // Call the third-party API function
return $this->callThirdPartyAPI($this->request->getJSON(),'verifyEmployeeNumber'); return $this->callThirdPartyAPI($this->request->getJSON(),'verifyEmployeeNumber');
// $result = ['user_verification' => false , 'message' => "User not found"];
// return $this->respond(['status' => 'failed','code' => 404,'data' => $result, 'post_enrollment'=> json_decode($apiResponse, true)],200);
} }
} catch (\Throwable $th) { } catch (\Throwable $th) {
return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500); return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500);
@ -113,11 +115,18 @@ class RestAuthenticationController extends AdminController
$email = $this->request->getJSON()->email; $email = $this->request->getJSON()->email;
$employeeData = $this->employeeModel->where('email_corporate', $email)->where('relationship', 'self') $employeeData = $this->employeeModel->select('employees.relationship,EP.employee_id')
->where('emp_status !=', 'truncated')->where('is_active', 1) ->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.email_corporate', $email)
->where('EP.is_active', 1)
->whereIn('EP.status', ['draft', 'enrolled'])
->first(); ->first();
if ($employeeData) { if (isset($employeeData['employee_id']))
{
$otp = random_int(100000, 999999); $otp = random_int(100000, 999999);
@ -161,10 +170,6 @@ class RestAuthenticationController extends AdminController
} else { } else {
// Call the third-party API function // Call the third-party API function
return $this->callThirdPartyAPI($this->request->getJSON(),'verifyEmployeeEmailId'); return $this->callThirdPartyAPI($this->request->getJSON(),'verifyEmployeeEmailId');
// $result = ['user_verification' => false , 'message' => "User not found"];
// return $this->respond(['status' => 'failed','code' => 404,'data' => $result, 'post_enrollment'=> json_decode($apiResponse, true)],200);
} }
} catch (\Throwable $th) { } catch (\Throwable $th) {
return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500); return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500);