HR api change : GWM
This commit is contained in:
parent
5194da85f7
commit
b0de0e9d84
@ -450,7 +450,7 @@ $routes->post("calculatePremium", "EmployeeRestController::calculatePremium");
|
||||
// $routes->post("employeeRest/createOrUpdateEmployeePolicySiAmount", "EmployeeRestController::createOrUpdateEmployeePolicySiAmount");
|
||||
// $routes->post("employeeRest/calculatePremium", "EmployeeRestController::calculatePremium");
|
||||
|
||||
$routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) {
|
||||
// $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) {
|
||||
|
||||
// $routes->post("getVerifiedUserData", "RestAuthenticationController::getVerifiedUserData");
|
||||
|
||||
@ -488,7 +488,7 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) {
|
||||
$routes->get("getEmployeeActiveOrInactivePolicy", "EmployeeRestController::getEmployeeActiveOrInactivePolicy");
|
||||
$routes->get("getFEContent", "EmployeeRestController::getFEContent");
|
||||
$routes->get("getAdvertisementImage", "EmployeeRestController::getAdvertisementImage");
|
||||
});
|
||||
// });
|
||||
$routes->get("getEmployeeActiveOrInactivePolicy", "EmployeeRestController::getEmployeeActiveOrInactivePolicy");
|
||||
$routes->get("sendPushNotification", "EmployeeRestController::sendPushNotification");
|
||||
$routes->post("sendEmail", "EmployeeRestController::send_email");
|
||||
|
||||
@ -2724,7 +2724,7 @@ class EmployeeRestController extends AdminController
|
||||
->where('client_policy.enrolment_visibility', 1 )
|
||||
->orderby('client_policy.id' , 'ASC')
|
||||
->findAll();
|
||||
|
||||
dd( $ClientPolicyData);
|
||||
// Retrieve employee and dependents data by passing the employee code
|
||||
$employeeData = $this->employeeModel->where('emp_code',$this->request->getGet('emp_code'))
|
||||
->where('client_id',$this->request->getGet('client_id'))
|
||||
|
||||
@ -75,7 +75,7 @@ class RestAuthenticationController extends AdminController
|
||||
|
||||
|
||||
|
||||
|
||||
// employee auth api's start
|
||||
|
||||
public function verifyEmployeeWithMobileNumber()
|
||||
{
|
||||
@ -268,6 +268,11 @@ class RestAuthenticationController extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
// employee auth api's end
|
||||
|
||||
|
||||
// HR auth api's start
|
||||
|
||||
public function verifyHrWithMobileNumber()
|
||||
{
|
||||
try {
|
||||
@ -295,17 +300,59 @@ class RestAuthenticationController extends AdminController
|
||||
public function verifyHrWithEmail()
|
||||
{
|
||||
try {
|
||||
$email = $this->request->getJSON()->email;
|
||||
|
||||
$data = $this->request->getJSON();
|
||||
|
||||
$email = $data->email;
|
||||
|
||||
$HrData = $this->hrModel->where('email', $email)
|
||||
->where('contact_type', 'client')
|
||||
->where('is_active', 1)
|
||||
->first();
|
||||
|
||||
|
||||
if ($HrData) {
|
||||
|
||||
$result = ['user_verification' => true ,'message' => "Verified Successfully"];
|
||||
return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
|
||||
$otp = random_int(100000, 999999);
|
||||
|
||||
$sql = "
|
||||
UPDATE level_contacts
|
||||
SET otp = ?
|
||||
WHERE email = ?
|
||||
AND contact_type = 'client'
|
||||
AND is_active = 1
|
||||
";
|
||||
|
||||
$db = db_connect();
|
||||
$update = $db->query($sql, [$otp, $email]);
|
||||
|
||||
if($update)
|
||||
{
|
||||
$data->otp = $otp;
|
||||
$this->callThirdPartyAPI($data, 'updateHROTP');
|
||||
|
||||
$common = [
|
||||
'login_type' => 'HR login',
|
||||
'login_email' => $email,
|
||||
'mail_type' => 'otp_mail'
|
||||
];
|
||||
$subject = 'Nhance user verification - OTP';
|
||||
$mail_content = $otp . ' is your verification code for Nhance.';
|
||||
$res = MailHelper::send_email(['mail' => $email, 'subject' => $subject, 'common' => $common, 'message' => $mail_content]);
|
||||
$this->myLogger->logme("info", $res);
|
||||
|
||||
if (json_decode($res)->status == 'success') {
|
||||
$result = ['user_verification' => true, 'message' => "Verified Successfully"];
|
||||
return $this->respond(['status' => 'success', 'code' => 200, 'data' => $result], 200);
|
||||
} else {
|
||||
$result = ['user_verification' => false, 'message' => "Mail sending failed , try again"];
|
||||
return $this->respond(['status' => 'failed', 'code' => 404, 'data' => $result], 200);
|
||||
}
|
||||
} else {
|
||||
|
||||
$result = ['user_verification' => false, 'message' => "Verification failed , try again"];
|
||||
return $this->respond(['status' => 'failed', 'code' => 404, 'data' => $result], 200);
|
||||
}
|
||||
|
||||
} else {
|
||||
// Call the third-party API function
|
||||
return $this->callThirdPartyAPI($this->request->getJSON(),'verifyHrWithEmail');
|
||||
@ -320,11 +367,23 @@ class RestAuthenticationController extends AdminController
|
||||
public function getVerifiedHrData()
|
||||
{
|
||||
try {
|
||||
$mobile_number = $this->request->getJSON()->mobile_number;
|
||||
$otp_verification = $this->request->getJSON()->otp_verification;
|
||||
// mobile number
|
||||
$otp_verification = isset($this->request->getJSON()->otp_verification) ? $this->request->getJSON()->otp_verification : null;
|
||||
$mobile_number = isset($this->request->getJSON()->mobile_number) ? $this->request->getJSON()->mobile_number : null;
|
||||
// email id
|
||||
$otp = isset($this->request->getJSON()->otp) ? $this->request->getJSON()->otp : null;
|
||||
$email = isset($this->request->getJSON()->email) ? $this->request->getJSON()->email : null;
|
||||
|
||||
if (isset($mobile_number))
|
||||
{
|
||||
$hrData = $this->hrModel->where('mobile', $mobile_number)->where('contact_type', 'client')->first();
|
||||
}else{
|
||||
$hrData = $this->hrModel->where('email', $email)->where('contact_type', 'client')->where('otp', $otp)->first();
|
||||
}
|
||||
|
||||
if ($hrData && $otp_verification == true || $hrData && isset($this->request->getJSON()->otp) )
|
||||
{
|
||||
|
||||
$hrData = $this->hrModel->where('mobile', $mobile_number)->first();
|
||||
if ($hrData && $otp_verification == true) {
|
||||
$auth = HttpRequestHelper::getRequestInfo();
|
||||
if ($auth) {
|
||||
$data = [
|
||||
@ -340,10 +399,24 @@ class RestAuthenticationController extends AdminController
|
||||
}
|
||||
|
||||
|
||||
$hrData = $this->hrModel ->select('level_contacts.* , client_branch.client_id as client_id')
|
||||
if(isset($this->request->getJSON()->mobile_number)){
|
||||
|
||||
$hrData = $this->hrModel ->select('level_contacts.* , client_branch.client_id as client_id')
|
||||
->join('client_branch', 'level_contacts.ref_id = client_branch.id', 'left')
|
||||
->where('level_contacts.mobile', $mobile_number )
|
||||
->where('level_contacts.contact_type', 'client')
|
||||
->find();
|
||||
|
||||
}else if(isset($this->request->getJSON()->otp)){
|
||||
|
||||
$this->hrModel->where('email', $email)->where('otp', $otp)->where('contact_type', 'client')->set(['otp'=>null])->update();
|
||||
|
||||
$hrData = $this->hrModel ->select('level_contacts.* , client_branch.client_id as client_id')
|
||||
->join('client_branch', 'level_contacts.ref_id = client_branch.id', 'left')
|
||||
->where('level_contacts.mobile', $mobile_number )
|
||||
->where('level_contacts.email', $email )
|
||||
->where('level_contacts.contact_type', 'client')
|
||||
->find();
|
||||
}
|
||||
|
||||
$result = JWTToken::encode($hrData['0']);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user