GWM
This commit is contained in:
parent
d9dd4068f0
commit
b1533f4f8c
@ -258,22 +258,7 @@ class RestAuthenticationController extends AdminController
|
||||
|
||||
$this->myLogger->logme("error", "REST-AUTH-CONTROLLER - verifyEmployeeWithEmailId: employee data both PRE & POST = " . json_encode($empdata));
|
||||
|
||||
// $employeeData = $this->employeeModel->select('
|
||||
// employees.relationship,
|
||||
// EP.employee_id,
|
||||
// employees.client_id,
|
||||
// employees.client_branch_id,
|
||||
// employees.email_corporate
|
||||
|
||||
// ')
|
||||
// ->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', 'expired'])
|
||||
// ->first();
|
||||
|
||||
|
||||
$employeeData = [];
|
||||
if (isset($empdata['pre']) && !empty($empdata['pre'])) {
|
||||
@ -281,15 +266,12 @@ class RestAuthenticationController extends AdminController
|
||||
$this->myLogger->logme("error", "REST-AUTH-CONTROLLER - verifyEmployeeWithEmailId: Using PRE data");
|
||||
}
|
||||
|
||||
$otp = random_int(100000, 999999);
|
||||
|
||||
if (isset($employeeData['employee_id'])) {
|
||||
if (isset($employeeData['employee_id']))
|
||||
{
|
||||
|
||||
$this->myLogger->logme("error", "REST-AUTH-CONTROLLER - verifyEmployeeWithEmailId: Valid employee found, generating OTP");
|
||||
$otp = random_int(100000, 999999);
|
||||
|
||||
// $update = $this->employeeModel->where('email_corporate', $email)->where('relationship', 'self')
|
||||
// ->where('is_active', 1)->set(array('otp' => $otp ))
|
||||
// ->update();
|
||||
|
||||
$sql = "
|
||||
UPDATE employees
|
||||
@ -303,7 +285,7 @@ class RestAuthenticationController extends AdminController
|
||||
";
|
||||
|
||||
$db = db_connect();
|
||||
// $update = $db->query($sql, [$otp, $email]);
|
||||
|
||||
$update = $db->query($sql, [$otp, $employeeData['employee_id']]);
|
||||
|
||||
$this->myLogger->logme("error", "REST-AUTH-CONTROLLER - verifyEmployeeWithEmailId: OTP update query executed. SQL = " . $db->getLastQuery());
|
||||
@ -311,17 +293,20 @@ class RestAuthenticationController extends AdminController
|
||||
if($update)
|
||||
{
|
||||
$this->myLogger->logme("error", "REST-AUTH-CONTROLLER - verifyEmployeeWithEmailId: OTP updated successfully in PRE DATABASE");
|
||||
$data->otp = $otp;
|
||||
|
||||
//If post-enrollment data exist update the same otp generated from pre-enrollment.
|
||||
if (isset($empdata['post']['client_id']) && !empty($empdata['post']['client_id'])) {
|
||||
$data->otp = $otp;
|
||||
$data->client_id = $empdata['post']['client_id'];
|
||||
$data->employee_id = $empdata['post']['employee_id'];
|
||||
$this->myLogger->logme("error", "REST-AUTH-CONTROLLER - verifyEmployeeWithEmailId: Attached otp, client_id and employee_id from POST data to update the otp");
|
||||
|
||||
$this->callThirdPartyAPI($data, 'updateEmpOTP');
|
||||
$this->myLogger->logme("error", "REST-AUTH-CONTROLLER - verifyEmployeeWithEmailId: Calling callThirdPartyAPI for updateEmpOTP");
|
||||
}
|
||||
|
||||
$this->myLogger->logme("error", "REST-AUTH-CONTROLLER - verifyEmployeeWithEmailId: Calling callThirdPartyAPI for updateEmpOTP");
|
||||
$this->callThirdPartyAPI($data, 'updateEmpOTP');
|
||||
|
||||
|
||||
//send Email
|
||||
$common = [
|
||||
'client_id' => $employeeData['client_id'],
|
||||
'client_branch_id' => $employeeData['client_branch_id'],
|
||||
@ -359,15 +344,16 @@ class RestAuthenticationController extends AdminController
|
||||
} else {
|
||||
|
||||
$this->myLogger->logme("error", "REST-AUTH-CONTROLLER - verifyEmployeeWithEmailId: Employee not found with email in the PRE DATABASE, falling back to third-party API");
|
||||
|
||||
// Call the third-party API function
|
||||
$apiParams = $this->request->getJSON();
|
||||
if (!empty($empdata['post']['client_id'])) {
|
||||
$apiParams->client_id = $empdata['post']['client_id'];
|
||||
}
|
||||
// print_r($apiParams); die;
|
||||
// Call the third-party API function
|
||||
$apiParams->otp = $otp;
|
||||
return $this->callThirdPartyAPI($apiParams, 'verifyEmployeeEmailId');
|
||||
log_message('error', ' ');
|
||||
log_message('error', '************************ PRE END ********************************');
|
||||
return $this->callThirdPartyAPI($apiParams, 'verifyEmployeeEmailId');
|
||||
}
|
||||
} catch (\Throwable $th) {
|
||||
log_message('error', ' ');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user