FEAT_CHECK_PASS
This commit is contained in:
parent
c8fc801225
commit
a9dae0ea76
@ -461,6 +461,8 @@ $routes->post("employeeRest/savePassword", "RestAuthenticationController::savePa
|
||||
$routes->post("employeeRest/changePassword", "RestAuthenticationController::changePassword");
|
||||
$routes->post("employeeRest/verifyPassword", "RestAuthenticationController::verifyPassword");
|
||||
$routes->post("employeeRest/verifyOtp", "RestAuthenticationController::verifyOtp");
|
||||
$routes->post("employeeRest/checkPassword", "RestAuthenticationController::checkPassword");
|
||||
|
||||
|
||||
// $routes->post("employeeRest/createOrUpdateEmployeePolicySiAmount", "EmployeeRestController::createOrUpdateEmployeePolicySiAmount");
|
||||
// $routes->post("employeeRest/calculatePremium", "EmployeeRestController::calculatePremium");
|
||||
|
||||
@ -1747,5 +1747,52 @@ class RestAuthenticationController extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
public function checkPassword()
|
||||
{
|
||||
$this->myLogger->logme("error", "REST-AUTH-CONTROLLER - checkPassword: Request payload = " . json_encode($this->request->getJSON() ?? []));
|
||||
|
||||
try {
|
||||
|
||||
$payload = $this->request->getJSON() ?? [];
|
||||
$mobile_number = $payload->mobile_number ?? null;
|
||||
$email_id = $payload->email_id ?? null;
|
||||
|
||||
$empdata = RestAuthHelper::getPreAndPostDataByEmailOrMobile(['email_id' => $email_id, 'mobile_number' => $mobile_number, 'check_mpin' => true]);
|
||||
// print_r($empdata); die;
|
||||
|
||||
if(empty($empdata)){
|
||||
$this->myLogger->logme("error", "REST-AUTH-CONTROLLER - checkPassword: No employee data found both PRE and POST");
|
||||
return $this->respond(['status' => 'failed','code' => 404,'data' => "Mpin - not found", 'Mpin' =>null],200);
|
||||
}
|
||||
|
||||
$this->myLogger->logme("error", "REST-AUTH-CONTROLLER - checkPassword: empdata = " . json_encode($empdata));
|
||||
|
||||
$employeeData = [];
|
||||
if (isset($empdata['pre']) && !empty($empdata['pre'])) {
|
||||
$employeeData = $empdata['pre'];
|
||||
$this->myLogger->logme("error", "REST-AUTH-CONTROLLER - checkPassword: Using PRE data from empdata");
|
||||
}
|
||||
|
||||
$requestData = $this->request->getJSON();
|
||||
if (isset($empdata['post']['client_id']) && !empty($empdata['post']['client_id'])) {
|
||||
$requestData->client_id = $empdata['post']['client_id'];
|
||||
$this->myLogger->logme("error", "REST-AUTH-CONTROLLER - checkPassword: Added client_id to requestData to get the POST employee data");
|
||||
}
|
||||
|
||||
|
||||
if ($employeeData && $employeeData["password"] != null) {
|
||||
$this->myLogger->logme("error", "REST-AUTH-CONTROLLER - checkPassword: Mpin - Exist");
|
||||
return $this->respond(['status' => 'success','code' => 200,'data' => "", 'message' => "Password - exist"],200);
|
||||
} else {
|
||||
$this->myLogger->logme("error", "REST-AUTH-CONTROLLER - checkPassword: Password - not found in PRE so call the thirdpartapi to the POST to check the MPIN");
|
||||
return $this->callThirdPartyAPI($requestData, 'checkPassword');
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$this->myLogger->logme("error", "REST-AUTH-CONTROLLER - Exception: " . $e->getMessage() . " --- Line: " . $e->getLine() . " --- Trace: " . $e->getTraceAsString());
|
||||
return $this->respond(['status' => 'failed','code' => 500,'data' => "", 'message' => $e->getMessage()],500);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user