CHANGE_MPIN_ISSUE : RV
This commit is contained in:
parent
c13ba6d3db
commit
a4595c36e7
@ -488,6 +488,7 @@ $routes->group("/api", ["filter" => "authJWT"], function ($routes) {
|
|||||||
|
|
||||||
$routes->post("employeeRest/saveMpin", "RestAuthenticationController::saveMpin");
|
$routes->post("employeeRest/saveMpin", "RestAuthenticationController::saveMpin");
|
||||||
$routes->post("employeeRest/updateMpin", "RestAuthenticationController::updateMpin");
|
$routes->post("employeeRest/updateMpin", "RestAuthenticationController::updateMpin");
|
||||||
|
$routes->post("employeeRest/getPostEmployeeDataForAuth", "RestAuthenticationController::getPostEmployeeDataForAuth");
|
||||||
|
|
||||||
|
|
||||||
$routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) {
|
$routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) {
|
||||||
|
|||||||
@ -22,6 +22,7 @@ use App\Models\EmployeeModel;
|
|||||||
use App\Models\AuthHistoryModel;
|
use App\Models\AuthHistoryModel;
|
||||||
use App\Models\LevelContactModel;
|
use App\Models\LevelContactModel;
|
||||||
use App\Models\HRAccessControlModel;
|
use App\Models\HRAccessControlModel;
|
||||||
|
use App\Models\ClientModel;
|
||||||
|
|
||||||
use Firebase\JWT\JWT;
|
use Firebase\JWT\JWT;
|
||||||
// require_once('../vendor/autoload.php');
|
// require_once('../vendor/autoload.php');
|
||||||
@ -37,6 +38,7 @@ class RestAuthenticationController extends AdminController
|
|||||||
protected $authHistoryModel;
|
protected $authHistoryModel;
|
||||||
protected $hrModel;
|
protected $hrModel;
|
||||||
protected $hrAccessControlModel;
|
protected $hrAccessControlModel;
|
||||||
|
protected $clientModel;
|
||||||
|
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
@ -48,6 +50,7 @@ class RestAuthenticationController extends AdminController
|
|||||||
$this->authHistoryModel = new AuthHistoryModel();
|
$this->authHistoryModel = new AuthHistoryModel();
|
||||||
$this->hrModel = new LevelContactModel();
|
$this->hrModel = new LevelContactModel();
|
||||||
$this->hrAccessControlModel = new HRAccessControlModel();
|
$this->hrAccessControlModel = new HRAccessControlModel();
|
||||||
|
$this->clientModel = new ClientModel();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,6 +106,7 @@ class RestAuthenticationController extends AdminController
|
|||||||
|
|
||||||
}
|
}
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $th) {
|
||||||
|
$this->myLogger->logme("error", ($th->getMessage().' --- '.$th->getLine()));
|
||||||
return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500);
|
return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -110,10 +114,13 @@ class RestAuthenticationController extends AdminController
|
|||||||
public function verifyEmployeeWithEmailId()
|
public function verifyEmployeeWithEmailId()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
log_message('error', json_encode($this->request->getJSON()));
|
||||||
$email = $this->request->getJSON()->email;
|
$email = $this->request->getJSON()->email;
|
||||||
|
$client_id = $this->request->getJSON()->client_id ?? null;
|
||||||
|
|
||||||
|
|
||||||
$employeeData = $this->employeeModel->select('
|
$builder = $this->employeeModel->select('
|
||||||
employees.relationship,
|
employees.relationship,
|
||||||
EP.employee_id,
|
EP.employee_id,
|
||||||
employees.client_id,
|
employees.client_id,
|
||||||
@ -124,19 +131,38 @@ class RestAuthenticationController extends AdminController
|
|||||||
->join('employee_polices EP', 'EP.employee_id = employees.id', 'inner')
|
->join('employee_polices EP', 'EP.employee_id = employees.id', 'inner')
|
||||||
->where('employees.is_active', 1)
|
->where('employees.is_active', 1)
|
||||||
->where('employees.relationship', 'Self')
|
->where('employees.relationship', 'Self')
|
||||||
->where('employees.emp_status !=', 'truncated')
|
->whereIn('employees.emp_status', ['active', 'expired'])
|
||||||
->where('employees.email_corporate', $email)
|
->where('employees.email_corporate', $email)
|
||||||
->where('EP.is_active', 1)
|
->where('EP.is_active', 1)
|
||||||
->whereIn('EP.status', ['active', 'expired'])
|
->whereIn('EP.status', ['active', 'expired']);
|
||||||
->first();
|
|
||||||
|
if (!empty($client_id)) {
|
||||||
|
$builder->where('employees.client_id', $client_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
$builder->orderBy('employees.id', 'desc');
|
||||||
|
$employeeData = $builder->first();
|
||||||
|
|
||||||
if (isset($employeeData['employee_id'])) {
|
if (isset($employeeData['employee_id'])) {
|
||||||
|
|
||||||
$otp = random_int(100000, 999999);
|
$otp = random_int(100000, 999999);
|
||||||
|
|
||||||
$update = $this->employeeModel->where('email_corporate', $email)->where('relationship', 'Self')
|
// $update = $this->employeeModel->where('email_corporate', $email)->where('relationship', 'Self')
|
||||||
->where('is_active', 1)->set(array('otp' => $otp))
|
// ->where('is_active', 1)->set(array('otp' => $otp))
|
||||||
->update();
|
// ->update();
|
||||||
|
|
||||||
|
$builder = $this->employeeModel
|
||||||
|
->where('email_corporate', $email)
|
||||||
|
->where('relationship', 'Self')
|
||||||
|
->where('is_active', 1)
|
||||||
|
->where('id', $employeeData['employee_id']);
|
||||||
|
|
||||||
|
if (!empty($client_id)) {
|
||||||
|
$builder->where('client_id', $client_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
$update = $builder->set(['otp' => $otp])->update();
|
||||||
|
|
||||||
if ($update) {
|
if ($update) {
|
||||||
|
|
||||||
$common = [
|
$common = [
|
||||||
@ -164,11 +190,14 @@ class RestAuthenticationController extends AdminController
|
|||||||
$result = ['user_verification' => false, 'message' => "Verification failed , try again"];
|
$result = ['user_verification' => false, 'message' => "Verification failed , try again"];
|
||||||
return $this->respond(['status' => 'failed', 'code' => 404, 'data' => $result], 200);
|
return $this->respond(['status' => 'failed', 'code' => 404, 'data' => $result], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$result = ['user_verification' => false, 'message' => "User not found"];
|
$result = ['user_verification' => false, 'message' => "User not found"];
|
||||||
return $this->respond(['status' => 'failed', 'code' => 404, 'data' => $result], 200);
|
return $this->respond(['status' => 'failed', 'code' => 404, 'data' => $result], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $th) {
|
||||||
|
$this->myLogger->logme("error", ($th->getMessage().' --- '.$th->getLine()));
|
||||||
return $this->respond(['status' => 'failed', 'code' => 500, 'data' => $th], 500);
|
return $this->respond(['status' => 'failed', 'code' => 500, 'data' => $th], 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -178,10 +207,24 @@ class RestAuthenticationController extends AdminController
|
|||||||
|
|
||||||
$email = $this->request->getJSON()->email;
|
$email = $this->request->getJSON()->email;
|
||||||
$otp = $this->request->getJSON()->otp;
|
$otp = $this->request->getJSON()->otp;
|
||||||
|
$client_id = $this->request->getJSON()->client_id ?? null;
|
||||||
|
$employee_id = $this->request->getJSON()->employee_id ?? null;
|
||||||
|
|
||||||
|
$builder = $this->employeeModel
|
||||||
|
->where('email_corporate', $email)
|
||||||
|
->where('relationship', 'Self')
|
||||||
|
->where('is_active', 1);
|
||||||
|
|
||||||
|
if (!empty($client_id)) {
|
||||||
|
$builder->where('client_id', $client_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($employee_id)) {
|
||||||
|
$builder->where('id', $employee_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
$builder->set(['otp' => $otp])->update();
|
||||||
|
|
||||||
$this->employeeModel->where('email_corporate', $email)->where('relationship', 'Self')
|
|
||||||
->where('is_active', 1)->set(array('otp' => $otp))
|
|
||||||
->update();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -333,6 +376,7 @@ class RestAuthenticationController extends AdminController
|
|||||||
|
|
||||||
$otp = isset($this->request->getJSON()->otp) ? $this->request->getJSON()->otp : null;
|
$otp = isset($this->request->getJSON()->otp) ? $this->request->getJSON()->otp : null;
|
||||||
$email_id = isset($this->request->getJSON()->email_id) ? $this->request->getJSON()->email_id : null;
|
$email_id = isset($this->request->getJSON()->email_id) ? $this->request->getJSON()->email_id : null;
|
||||||
|
$client_id = $this->request->getJSON()->client_id ?? null;
|
||||||
|
|
||||||
if (isset($this->request->getJSON()->login_by_hr))
|
if (isset($this->request->getJSON()->login_by_hr))
|
||||||
{
|
{
|
||||||
@ -341,7 +385,7 @@ class RestAuthenticationController extends AdminController
|
|||||||
if (isset($mobile_number))
|
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
|
$builder = $this->employeeModel
|
||||||
->select('employees.*')
|
->select('employees.*')
|
||||||
->join('employee_polices', 'employees.id = employee_polices.employee_id')
|
->join('employee_polices', 'employees.id = employee_polices.employee_id')
|
||||||
->where('employees.mobile', $mobile_number)
|
->where('employees.mobile', $mobile_number)
|
||||||
@ -349,22 +393,32 @@ class RestAuthenticationController extends AdminController
|
|||||||
->where('employee_polices.is_active', 1)
|
->where('employee_polices.is_active', 1)
|
||||||
->whereIn('employee_polices.status', ['active', 'expired'])
|
->whereIn('employee_polices.status', ['active', 'expired'])
|
||||||
->where('employees.is_active', 1)
|
->where('employees.is_active', 1)
|
||||||
->whereIn('employees.emp_status', ['active', 'expired'])
|
->whereIn('employees.emp_status', ['active', 'expired']);
|
||||||
->where('employees.emp_status !=', 'truncated')
|
|
||||||
->first();
|
if (!empty($client_id)) {
|
||||||
|
$builder->where('employees.client_id', $client_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
$employeeData = $builder->orderBy('employees.id', 'desc')->first();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// $employeeData = $this->employeeModel->where('email_corporate', $email_id)->where('otp', $otp)->where('relationship', 'self')->where('emp_status !=', 'truncated')->where('is_active', 1)->first();
|
// $employeeData = $this->employeeModel->where('email_corporate', $email_id)->where('otp', $otp)->where('relationship', 'self')->where('emp_status !=', 'truncated')->where('is_active', 1)->first();
|
||||||
$employeeData = $this->employeeModel
|
$builder = $this->employeeModel
|
||||||
->select('employees.*')
|
->select('employees.*')
|
||||||
->join('employee_polices', 'employees.id = employee_polices.employee_id')
|
->join('employee_polices', 'employees.id = employee_polices.employee_id')
|
||||||
->where('employees.email_corporate', $email_id)
|
->where('employees.email_corporate', $email_id)
|
||||||
->where('employees.relationship', 'Self')
|
->where('employees.relationship', 'Self')
|
||||||
->where('employee_polices.is_active', 1)
|
->where('employee_polices.is_active', 1)
|
||||||
->whereIn('employee_polices.status', ['active', 'expired'])
|
->whereIn('employee_polices.status', ['active', 'expired'])
|
||||||
->where('employees.is_active', 1)
|
->where('employees.is_active', 1)
|
||||||
->whereIn('employees.emp_status', ['active', 'expired'])
|
->whereIn('employees.emp_status', ['active', 'expired'])
|
||||||
->where('otp', $otp)
|
->where('otp', $otp);
|
||||||
->first();
|
|
||||||
|
if (!empty($client_id)) {
|
||||||
|
$builder->where('employees.client_id', $client_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
$employeeData = $builder->orderBy('employees.id', 'desc')->first();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -622,23 +676,29 @@ class RestAuthenticationController extends AdminController
|
|||||||
|
|
||||||
$mobile_number = isset($this->request->getJSON()->mobile_number) ? $this->request->getJSON()->mobile_number : null;
|
$mobile_number = isset($this->request->getJSON()->mobile_number) ? $this->request->getJSON()->mobile_number : null;
|
||||||
$email_id = isset($this->request->getJSON()->email_id) ? $this->request->getJSON()->email_id : null;
|
$email_id = isset($this->request->getJSON()->email_id) ? $this->request->getJSON()->email_id : null;
|
||||||
|
$client_id = $this->request->getJSON()->client_id ?? null;
|
||||||
|
|
||||||
if (isset($mobile_number)) {
|
if (isset($mobile_number)) {
|
||||||
// $employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first();
|
// $employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first();
|
||||||
$employeeData = $this->employeeModel
|
$builder = $this->employeeModel
|
||||||
->select('employees.*')
|
->select('employees.*')
|
||||||
->join('employee_polices', 'employees.id = employee_polices.employee_id')
|
->join('employee_polices', 'employees.id = employee_polices.employee_id')
|
||||||
->where('employees.mobile', $mobile_number)
|
->where('employees.mobile', $mobile_number)
|
||||||
->where('employees.relationship', 'Self')
|
->where('employees.relationship', 'Self')
|
||||||
->where('employee_polices.is_active', 1)
|
->where('employee_polices.is_active', 1)
|
||||||
->whereIn('employee_polices.status', ['active', 'expired'])
|
->whereIn('employee_polices.status', ['active', 'expired'])
|
||||||
->where('employees.is_active', 1)
|
->where('employees.is_active', 1)
|
||||||
->whereIn('employees.emp_status', ['active', 'expired'])
|
->whereIn('employees.emp_status', ['active', 'expired']);
|
||||||
->orderBy('id', 'desc')
|
|
||||||
->first();
|
if (!empty($client_id)) {
|
||||||
|
$builder->where('employees.client_id', $client_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
$employeeData = $builder->orderBy('employees.id', 'desc')->first();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// $employeeData = $this->employeeModel->where('email_corporate', $email_id)->where('relationship', 'self')->first();
|
// $employeeData = $this->employeeModel->where('email_corporate', $email_id)->where('relationship', 'self')->first();
|
||||||
$employeeData = $this->employeeModel
|
$builder = $this->employeeModel
|
||||||
->select('employees.*')
|
->select('employees.*')
|
||||||
->join('employee_polices', 'employees.id = employee_polices.employee_id')
|
->join('employee_polices', 'employees.id = employee_polices.employee_id')
|
||||||
->where('employees.email_corporate', $email_id)
|
->where('employees.email_corporate', $email_id)
|
||||||
@ -646,9 +706,13 @@ class RestAuthenticationController extends AdminController
|
|||||||
->where('employee_polices.is_active', 1)
|
->where('employee_polices.is_active', 1)
|
||||||
->whereIn('employee_polices.status', ['active', 'expired'])
|
->whereIn('employee_polices.status', ['active', 'expired'])
|
||||||
->where('employees.is_active', 1)
|
->where('employees.is_active', 1)
|
||||||
->whereIn('employees.emp_status', ['active', 'expired'])
|
->whereIn('employees.emp_status', ['active', 'expired']);
|
||||||
->orderBy('id', 'desc')
|
|
||||||
->first();
|
if (!empty($client_id)) {
|
||||||
|
$builder->where('employees.client_id', $client_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
$employeeData = $builder->orderBy('employees.id', 'desc')->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
$mpin = $this->request->getJSON()->mpin;
|
$mpin = $this->request->getJSON()->mpin;
|
||||||
@ -681,6 +745,7 @@ class RestAuthenticationController extends AdminController
|
|||||||
|
|
||||||
}
|
}
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $th) {
|
||||||
|
$this->myLogger->logme("error", ($th->getMessage().' --- '.$th->getLine()));
|
||||||
return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500);
|
return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -693,6 +758,7 @@ class RestAuthenticationController extends AdminController
|
|||||||
$email_id = isset($this->request->getJSON()->email_id) ? $this->request->getJSON()->email_id : null;
|
$email_id = isset($this->request->getJSON()->email_id) ? $this->request->getJSON()->email_id : null;
|
||||||
$old_mpin = $this->request->getJSON()->old_mpin;
|
$old_mpin = $this->request->getJSON()->old_mpin;
|
||||||
$mpin = $this->request->getJSON()->new_mpin;
|
$mpin = $this->request->getJSON()->new_mpin;
|
||||||
|
$client_id = $this->request->getJSON()->client_id ?? null;
|
||||||
|
|
||||||
// if (isset($mobile_number))
|
// if (isset($mobile_number))
|
||||||
// {
|
// {
|
||||||
@ -703,7 +769,7 @@ class RestAuthenticationController extends AdminController
|
|||||||
|
|
||||||
if (isset($mobile_number)) {
|
if (isset($mobile_number)) {
|
||||||
// $employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('mpin', $old_mpin)->where('relationship', 'self')->first();
|
// $employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('mpin', $old_mpin)->where('relationship', 'self')->first();
|
||||||
$employeeData = $this->employeeModel
|
$builder = $this->employeeModel
|
||||||
->select('employees.*')
|
->select('employees.*')
|
||||||
->join('employee_polices', 'employees.id = employee_polices.employee_id')
|
->join('employee_polices', 'employees.id = employee_polices.employee_id')
|
||||||
->where('employees.mobile', $mobile_number)
|
->where('employees.mobile', $mobile_number)
|
||||||
@ -712,12 +778,17 @@ class RestAuthenticationController extends AdminController
|
|||||||
->whereIn('employee_polices.status', ['active'])
|
->whereIn('employee_polices.status', ['active'])
|
||||||
->where('employees.is_active', 1)
|
->where('employees.is_active', 1)
|
||||||
->whereIn('employees.emp_status', ['active'])
|
->whereIn('employees.emp_status', ['active'])
|
||||||
->where('employees.mpin', $old_mpin)
|
->where('employees.mpin', $old_mpin);
|
||||||
->orderBy('id', 'desc')
|
|
||||||
->first();
|
if (!empty($client_id)) {
|
||||||
|
$builder->where('employees.client_id', $client_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
$employeeData = $builder->orderBy('employees.id', 'desc')->first();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// $employeeData = $this->employeeModel->where('email_corporate', $email_id)->where('mpin', $old_mpin)->where('relationship', 'self')->first();
|
// $employeeData = $this->employeeModel->where('email_corporate', $email_id)->where('mpin', $old_mpin)->where('relationship', 'self')->first();
|
||||||
$employeeData = $this->employeeModel
|
$builder = $this->employeeModel
|
||||||
->select('employees.*')
|
->select('employees.*')
|
||||||
->join('employee_polices', 'employees.id = employee_polices.employee_id')
|
->join('employee_polices', 'employees.id = employee_polices.employee_id')
|
||||||
->where('employees.email_corporate', $email_id)
|
->where('employees.email_corporate', $email_id)
|
||||||
@ -726,9 +797,13 @@ class RestAuthenticationController extends AdminController
|
|||||||
->whereIn('employee_polices.status', ['active'])
|
->whereIn('employee_polices.status', ['active'])
|
||||||
->where('employees.is_active', 1)
|
->where('employees.is_active', 1)
|
||||||
->whereIn('employees.emp_status', ['active'])
|
->whereIn('employees.emp_status', ['active'])
|
||||||
->where('employees.mpin', $old_mpin)
|
->where('employees.mpin', $old_mpin);
|
||||||
->orderBy('id', 'desc')
|
|
||||||
->first();
|
if (!empty($client_id)) {
|
||||||
|
$builder->where('employees.client_id', $client_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
$employeeData = $builder->orderBy('employees.id', 'desc')->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -750,6 +825,7 @@ class RestAuthenticationController extends AdminController
|
|||||||
|
|
||||||
}
|
}
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $th) {
|
||||||
|
$this->myLogger->logme("error", ($th->getMessage().' --- '.$th->getLine()));
|
||||||
return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500);
|
return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -823,6 +899,7 @@ class RestAuthenticationController extends AdminController
|
|||||||
$mobile_number = $requestData['mobile_number'] ?? null;
|
$mobile_number = $requestData['mobile_number'] ?? null;
|
||||||
$email_id = $requestData['email_id'] ?? null;
|
$email_id = $requestData['email_id'] ?? null;
|
||||||
$mpin = $requestData['mpin'] ?? null;
|
$mpin = $requestData['mpin'] ?? null;
|
||||||
|
$client_id = $requestData['client_id'] ?? null;
|
||||||
// print_r($mpin);
|
// print_r($mpin);
|
||||||
|
|
||||||
if (!$mpin) {
|
if (!$mpin) {
|
||||||
@ -830,7 +907,8 @@ class RestAuthenticationController extends AdminController
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($mobile_number) {
|
if ($mobile_number) {
|
||||||
$employeeData = $this->employeeModel
|
|
||||||
|
$builder = $this->employeeModel
|
||||||
->select('employees.*')
|
->select('employees.*')
|
||||||
->join('employee_polices', 'employees.id = employee_polices.employee_id')
|
->join('employee_polices', 'employees.id = employee_polices.employee_id')
|
||||||
->where('employees.mobile', $mobile_number)
|
->where('employees.mobile', $mobile_number)
|
||||||
@ -838,10 +916,18 @@ class RestAuthenticationController extends AdminController
|
|||||||
->where('employee_polices.is_active', 1)
|
->where('employee_polices.is_active', 1)
|
||||||
->whereIn('employee_polices.status', ['active'])
|
->whereIn('employee_polices.status', ['active'])
|
||||||
->where('employees.is_active', 1)
|
->where('employees.is_active', 1)
|
||||||
->whereIn('employees.emp_status', ['active'])
|
->whereIn('employees.emp_status', ['active']);
|
||||||
->first();
|
|
||||||
|
if (!empty($client_id)) {
|
||||||
|
$builder->where('employees.client_id', $client_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
$employeeData = $builder->orderBy('employees.id', 'desc')->first();
|
||||||
|
|
||||||
|
|
||||||
} elseif ($email_id) {
|
} elseif ($email_id) {
|
||||||
$employeeData = $this->employeeModel
|
|
||||||
|
$builder = $this->employeeModel
|
||||||
->select('employees.*')
|
->select('employees.*')
|
||||||
->join('employee_polices', 'employees.id = employee_polices.employee_id')
|
->join('employee_polices', 'employees.id = employee_polices.employee_id')
|
||||||
->where('employees.email_corporate', $email_id)
|
->where('employees.email_corporate', $email_id)
|
||||||
@ -849,8 +935,14 @@ class RestAuthenticationController extends AdminController
|
|||||||
->where('employee_polices.is_active', 1)
|
->where('employee_polices.is_active', 1)
|
||||||
->whereIn('employee_polices.status', ['active'])
|
->whereIn('employee_polices.status', ['active'])
|
||||||
->where('employees.is_active', 1)
|
->where('employees.is_active', 1)
|
||||||
->whereIn('employees.emp_status', ['active'])
|
->whereIn('employees.emp_status', ['active']);
|
||||||
->first();
|
|
||||||
|
if (!empty($client_id)) {
|
||||||
|
$builder->where('employees.client_id', $client_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
$employeeData = $builder->orderBy('employees.id', 'desc')->first();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return $this->respond(['status' => 'failed', 'code' => 400, 'data' => 'Mobile number or Email ID is required'], 400);
|
return $this->respond(['status' => 'failed', 'code' => 400, 'data' => 'Mobile number or Email ID is required'], 400);
|
||||||
}
|
}
|
||||||
@ -885,6 +977,7 @@ class RestAuthenticationController extends AdminController
|
|||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
$this->myLogger->logme("error", ($e->getMessage().' --- '.$e->getLine()));
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'code' => 500,
|
'code' => 500,
|
||||||
@ -899,11 +992,13 @@ class RestAuthenticationController extends AdminController
|
|||||||
$mobile_number = isset($this->request->getJSON()->mobile_number) ? $this->request->getJSON()->mobile_number : null;
|
$mobile_number = isset($this->request->getJSON()->mobile_number) ? $this->request->getJSON()->mobile_number : null;
|
||||||
$email_id = isset($this->request->getJSON()->email_id) ? $this->request->getJSON()->email_id : null;
|
$email_id = isset($this->request->getJSON()->email_id) ? $this->request->getJSON()->email_id : null;
|
||||||
// $mpin = $this->request->getJSON()->mpin;
|
// $mpin = $this->request->getJSON()->mpin;
|
||||||
|
$client_id = $this->request->getJSON()->client_id ?? null;
|
||||||
|
|
||||||
|
|
||||||
if (isset($mobile_number))
|
if (isset($mobile_number))
|
||||||
{
|
{
|
||||||
// $employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first();
|
// $employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first();
|
||||||
$employeeData = $this->employeeModel
|
$builder = $this->employeeModel
|
||||||
->select('employees.*')
|
->select('employees.*')
|
||||||
->join('employee_polices', 'employees.id = employee_polices.employee_id')
|
->join('employee_polices', 'employees.id = employee_polices.employee_id')
|
||||||
->where('employees.mobile', $mobile_number)
|
->where('employees.mobile', $mobile_number)
|
||||||
@ -911,12 +1006,16 @@ class RestAuthenticationController extends AdminController
|
|||||||
->where('employee_polices.is_active', 1)
|
->where('employee_polices.is_active', 1)
|
||||||
->whereIn('employee_polices.status', ['active', 'expired'])
|
->whereIn('employee_polices.status', ['active', 'expired'])
|
||||||
->where('employees.is_active', 1)
|
->where('employees.is_active', 1)
|
||||||
->whereIn('employees.emp_status', ['active', 'expired'])
|
->whereIn('employees.emp_status', ['active', 'expired']);
|
||||||
->orderBy('id', 'desc')
|
if (!empty($client_id)) {
|
||||||
->first();
|
$builder->where('employees.client_id', $client_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
$employeeData = $builder->orderBy('employees.id', 'desc')->first();
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
// $employeeData = $this->employeeModel->where('email_corporate', $email_id)->where('relationship', 'self')->first();
|
// $employeeData = $this->employeeModel->where('email_corporate', $email_id)->where('relationship', 'self')->first();
|
||||||
$employeeData = $this->employeeModel
|
$builder = $this->employeeModel
|
||||||
->select('employees.*')
|
->select('employees.*')
|
||||||
->join('employee_polices', 'employees.id = employee_polices.employee_id')
|
->join('employee_polices', 'employees.id = employee_polices.employee_id')
|
||||||
->where('employees.email_corporate', $email_id)
|
->where('employees.email_corporate', $email_id)
|
||||||
@ -924,9 +1023,13 @@ class RestAuthenticationController extends AdminController
|
|||||||
->where('employee_polices.is_active', 1)
|
->where('employee_polices.is_active', 1)
|
||||||
->whereIn('employee_polices.status', ['active', 'expired'])
|
->whereIn('employee_polices.status', ['active', 'expired'])
|
||||||
->where('employees.is_active', 1)
|
->where('employees.is_active', 1)
|
||||||
->whereIn('employees.emp_status', ['active', 'expired'])
|
->whereIn('employees.emp_status', ['active', 'expired']);
|
||||||
->orderBy('id', 'desc')
|
|
||||||
->first();
|
if (!empty($client_id)) {
|
||||||
|
$builder->where('employees.client_id', $client_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
$employeeData = $builder->orderBy('employees.id', 'desc')->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -937,6 +1040,7 @@ class RestAuthenticationController extends AdminController
|
|||||||
return $this->respond(['status' => 'failed','code' => 404,'data' => "Mpin - not found", 'Mpin' =>null],200);
|
return $this->respond(['status' => 'failed','code' => 404,'data' => "Mpin - not found", 'Mpin' =>null],200);
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
$this->myLogger->logme("error", ($e->getMessage().' --- '.$e->getLine()));
|
||||||
return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()],500);
|
return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()],500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -949,6 +1053,7 @@ class RestAuthenticationController extends AdminController
|
|||||||
$json = $this->request->getJSON();
|
$json = $this->request->getJSON();
|
||||||
$mobile_number = $json->mobile_number ?? null;
|
$mobile_number = $json->mobile_number ?? null;
|
||||||
$email_id = $json->email_id ?? null;
|
$email_id = $json->email_id ?? null;
|
||||||
|
$client_id = $json->client_id ?? null;
|
||||||
|
|
||||||
log_message('info', 'Received input - Mobile: ' . var_export($mobile_number, true) . ', Email: ' . var_export($email_id, true));
|
log_message('info', 'Received input - Mobile: ' . var_export($mobile_number, true) . ', Email: ' . var_export($email_id, true));
|
||||||
|
|
||||||
@ -964,20 +1069,28 @@ class RestAuthenticationController extends AdminController
|
|||||||
|
|
||||||
// Step 2: Fetch employee data
|
// Step 2: Fetch employee data
|
||||||
if ($mobile_number) {
|
if ($mobile_number) {
|
||||||
|
|
||||||
log_message('info', 'Looking up employee by mobile number: ' . $mobile_number);
|
log_message('info', 'Looking up employee by mobile number: ' . $mobile_number);
|
||||||
$employeeData = $this->employeeModel
|
$builder = $this->employeeModel
|
||||||
->select('employees.*')
|
->select('employees.*')
|
||||||
->join('employee_polices', 'employees.id = employee_polices.employee_id')
|
->join('employee_polices', 'employees.id = employee_polices.employee_id')
|
||||||
->where('employees.mobile', $mobile_number)
|
->where('employees.mobile', $mobile_number)
|
||||||
->where('employees.relationship', 'Self')
|
->where('employees.relationship', 'Self')
|
||||||
->where('employee_polices.is_active', 1)
|
->where('employee_polices.is_active', 1)
|
||||||
->where('employee_polices.status', ['active'])
|
->where('employee_polices.status', ['active'])
|
||||||
->where('employees.is_active', 1)
|
->where('employees.is_active', 1)
|
||||||
->where('employees.emp_status', ['active'])
|
->where('employees.emp_status', ['active']);
|
||||||
->first();
|
|
||||||
|
if (!empty($client_id)) {
|
||||||
|
$builder->where('employees.client_id', $client_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
$employeeData = $builder->orderBy('employees.id', 'desc')->first();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
log_message('info', 'Looking up employee by email: ' . $email_id);
|
log_message('info', 'Looking up employee by email: ' . $email_id);
|
||||||
$employeeData = $this->employeeModel
|
$builder = $this->employeeModel
|
||||||
->select('employees.*')
|
->select('employees.*')
|
||||||
->join('employee_polices', 'employees.id = employee_polices.employee_id')
|
->join('employee_polices', 'employees.id = employee_polices.employee_id')
|
||||||
->where('employees.email_corporate', $email_id)
|
->where('employees.email_corporate', $email_id)
|
||||||
@ -985,8 +1098,13 @@ class RestAuthenticationController extends AdminController
|
|||||||
->where('employee_polices.is_active', 1)
|
->where('employee_polices.is_active', 1)
|
||||||
->where('employee_polices.status', ['active'])
|
->where('employee_polices.status', ['active'])
|
||||||
->where('employees.is_active', 1)
|
->where('employees.is_active', 1)
|
||||||
->where('employees.emp_status', ['active'])
|
->where('employees.emp_status', ['active']);
|
||||||
->first();
|
|
||||||
|
if (!empty($client_id)) {
|
||||||
|
$builder->where('employees.client_id', $client_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
$employeeData = $builder->orderBy('employees.id', 'desc')->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
log_message('info', '$employeeData : ' . json_encode($employeeData));
|
log_message('info', '$employeeData : ' . json_encode($employeeData));
|
||||||
@ -1028,7 +1146,7 @@ class RestAuthenticationController extends AdminController
|
|||||||
log_message('warning', 'Employee not found locally. Falling back to third-party API.');
|
log_message('warning', 'Employee not found locally. Falling back to third-party API.');
|
||||||
return $this->respond(['status' => 'failed','code' => 404,'data' => "Employee not found"],200); }
|
return $this->respond(['status' => 'failed','code' => 404,'data' => "Employee not found"],200); }
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
log_message('error', 'Exception in forgotMPIN(): ' . $e->getMessage());
|
$this->myLogger->logme("error", ($e->getMessage().' --- '.$e->getLine()));
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'code' => 500,
|
'code' => 500,
|
||||||
@ -1063,6 +1181,81 @@ class RestAuthenticationController extends AdminController
|
|||||||
return redirect()->to($url);
|
return redirect()->to($url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getPostEmployeeDataForAuth()
|
||||||
|
{
|
||||||
|
$params = $this->request->getJSON(true);
|
||||||
|
// print_r( $params); die;
|
||||||
|
|
||||||
|
$mobile_number = $params['mobile_number'] ?? null;
|
||||||
|
$email_id = $params['email_id'] ?? null;
|
||||||
|
$otp = $params['otp'] ?? null;
|
||||||
|
$old_mpin = $params['old_mpin'] ?? null;
|
||||||
|
|
||||||
|
if (empty($mobile_number) && empty($email_id)) {
|
||||||
|
return $this->respond([
|
||||||
|
'status' => 'failed',
|
||||||
|
'message' => 'Mobile number or Email ID is required.',
|
||||||
|
'data' => [],
|
||||||
|
], 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($mobile_number)) {
|
||||||
|
|
||||||
|
$builder = $this->employeeModel
|
||||||
|
->select('employees.id as employee_id, employees.*')
|
||||||
|
->join('employee_polices EP', 'EP.employee_id = employees.id', 'inner')
|
||||||
|
->where('employees.is_active', 1)
|
||||||
|
->where("TRIM(employees.relationship) = 'self'", null, false)
|
||||||
|
->whereIn('employees.emp_status', ['active', 'expired'])
|
||||||
|
->where('employees.mobile', $mobile_number)
|
||||||
|
->where('EP.is_active', 1)
|
||||||
|
->whereIn('EP.status', ['active', 'expired']);
|
||||||
|
|
||||||
|
if (!empty($old_mpin)) {
|
||||||
|
$builder->where('employees.mpin', $old_mpin);
|
||||||
|
}
|
||||||
|
|
||||||
|
$employeeData = $builder->orderBy('employees.id', 'desc')->first();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$builder = $this->employeeModel
|
||||||
|
->select('employees.id as employee_id, employees.*')
|
||||||
|
->join('employee_polices EP', 'EP.employee_id = employees.id', 'inner')
|
||||||
|
->where('employees.is_active', 1)
|
||||||
|
->where("TRIM(employees.relationship) = 'self'", null, false)
|
||||||
|
->whereIn('employees.emp_status', ['active', 'expired'])
|
||||||
|
->where('employees.email_corporate', $email_id)
|
||||||
|
->where('EP.is_active', 1)
|
||||||
|
->whereIn('EP.status', ['active', 'expired']);
|
||||||
|
|
||||||
|
if (!empty($otp)) {
|
||||||
|
$builder->where('employees.otp', $otp);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($old_mpin)) {
|
||||||
|
$builder->where('employees.mpin', $old_mpin);
|
||||||
|
}
|
||||||
|
|
||||||
|
$employeeData = $builder->orderBy('employees.id', 'desc')->first();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($employeeData) {
|
||||||
|
|
||||||
|
$client_data = $this->clientModel->where('is_active', 1)->where('id', $employeeData['client_id'])->first();
|
||||||
|
$employeeData['client_short_name'] = $client_data['short_name'];
|
||||||
|
|
||||||
|
return $this->respond([
|
||||||
|
'status' => 'success',
|
||||||
|
'data' => $employeeData,
|
||||||
|
], 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->respond([
|
||||||
|
'status' => 'failed',
|
||||||
|
'message' => 'No employee found.',
|
||||||
|
'data' => [],
|
||||||
|
], 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user