Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev
This commit is contained in:
commit
22d49c0fbb
@ -349,6 +349,9 @@ class EmployeeServiceController extends AdminController
|
|||||||
unset($excel_data[0]);
|
unset($excel_data[0]);
|
||||||
$relationship = $this->general_relationships;
|
$relationship = $this->general_relationships;
|
||||||
|
|
||||||
|
|
||||||
|
if(in_array($file['action'],['inception','addition','dependent_addition']))// the below funcitons are only for I,DA,A
|
||||||
|
{
|
||||||
$employee_data_group_by_family = data_group_by_family($excel_data);
|
$employee_data_group_by_family = data_group_by_family($excel_data);
|
||||||
|
|
||||||
$is_self_available_in_policy_terms = false;
|
$is_self_available_in_policy_terms = false;
|
||||||
@ -452,7 +455,8 @@ class EmployeeServiceController extends AdminController
|
|||||||
$result['error_data'][$rowid]['name_of_emp_dep']['error'][] = "Record already exists";
|
$result['error_data'][$rowid]['name_of_emp_dep']['error'][] = "Record already exists";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}// end of foreach
|
||||||
|
}// end of if current action I,DA,A
|
||||||
|
|
||||||
// s($result);
|
// s($result);
|
||||||
// die();
|
// die();
|
||||||
@ -857,9 +861,9 @@ class EmployeeServiceController extends AdminController
|
|||||||
if($slab_value['si'] == $row[3])
|
if($slab_value['si'] == $row[3])
|
||||||
{
|
{
|
||||||
$group_key = rand(100000, 999999);
|
$group_key = rand(100000, 999999);
|
||||||
$this->empEndorsementModel->save(['pk' => (int)$employee['id'],'emp_code' => $employee['emp_code'],'table_name' => 'employee_polices','actions' => 'si','name' => $employee['name'],'field_name' => 'basic_cover_si','old_value' => $employee_policy['basic_cover_si'],'new_value' => $row[3],'created_by' => $file['created_by'],'remarks' => 'general si enhancement','group_key' => $group_key,'file_id' => $file['id']]);
|
$this->empEndorsementModel->save(['pk' => (int)$employee_policy['id'],'emp_code' => $employee['emp_code'],'table_name' => 'employee_polices','actions' => 'si','name' => $employee['name'],'field_name' => 'basic_cover_si','old_value' => $employee_policy['basic_cover_si'],'new_value' => $row[3],'created_by' => $file['created_by'],'remarks' => 'general si enhancement','group_key' => $group_key,'file_id' => $file['id']]);
|
||||||
$this->empEndorsementModel->save(['pk' => (int)$employee['id'],'emp_code' => $employee['emp_code'],'table_name' => 'employee_polices','actions' => 'si','name' => $employee['name'],'field_name' => 'premium','old_value' => $employee_policy['premium'],'new_value' => $slab_value['premium'],'created_by' => $file['created_by'],'remarks' => 'general si enhancement','group_key' => $group_key,'file_id' => $file['id']]);
|
$this->empEndorsementModel->save(['pk' => (int)$employee_policy['id'],'emp_code' => $employee['emp_code'],'table_name' => 'employee_polices','actions' => 'si','name' => $employee['name'],'field_name' => 'premium','old_value' => $employee_policy['premium'],'new_value' => $slab_value['premium'],'created_by' => $file['created_by'],'remarks' => 'general si enhancement','group_key' => $group_key,'file_id' => $file['id']]);
|
||||||
$this->empEndorsementModel->save(['pk' => (int)$employee['id'],'emp_code' => $employee['emp_code'],'table_name' => 'employee_polices','actions' => 'si','name' => $employee['name'],'field_name' => 'si_enhancement_date','old_value' => null,'new_value' => change_date_format($row[4],'d-M-Y','Y-m-d'),'created_by' => $file['created_by'],'remarks' => 'general si enhancement','group_key' => $group_key,'file_id' => $file['id']]);
|
$this->empEndorsementModel->save(['pk' => (int)$employee_policy['id'],'emp_code' => $employee['emp_code'],'table_name' => 'employee_polices','actions' => 'si','name' => $employee['name'],'field_name' => 'si_enhancement_date','old_value' => null,'new_value' => change_date_format($row[4],'d-M-Y','Y-m-d'),'created_by' => $file['created_by'],'remarks' => 'general si enhancement','group_key' => $group_key,'file_id' => $file['id']]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,6 +12,7 @@ use ReflectionClass;
|
|||||||
|
|
||||||
require_once('../vendor/autoload.php');
|
require_once('../vendor/autoload.php');
|
||||||
|
|
||||||
|
use App\Models\EmployeeModel;
|
||||||
|
|
||||||
|
|
||||||
class AuthJWT implements FilterInterface
|
class AuthJWT implements FilterInterface
|
||||||
@ -19,27 +20,27 @@ class AuthJWT implements FilterInterface
|
|||||||
public function before(RequestInterface $request, $arguments = null)
|
public function before(RequestInterface $request, $arguments = null)
|
||||||
{
|
{
|
||||||
$jwt = $request->getHeader('Authorization');
|
$jwt = $request->getHeader('Authorization');
|
||||||
|
$model = new EmployeeModel();
|
||||||
|
|
||||||
if ($jwt) {
|
if ($jwt) {
|
||||||
if (JWTToken::validateJWT($jwt)) {
|
if (JWTToken::validateJWT($jwt)) {
|
||||||
$data = JWTToken::validateJWT($jwt);
|
$data = JWTToken::validateJWT($jwt);
|
||||||
$data = json_decode($data);
|
$data = json_decode($data);
|
||||||
|
|
||||||
if ($data->status) {
|
$id = $data->decoded->id;
|
||||||
// $auth = $request->getHeader("Authorization");
|
$user_data = $model->where('id', $id)->first();
|
||||||
// $decodedToken = $data->decoded;
|
|
||||||
|
|
||||||
// $decodedToken->exp += 30;
|
if($user_data['token_time_out'] > time()){
|
||||||
// $newJwt = JWTToken::encode((array)$decodedToken);
|
$data =["token_time_out" => time() + getenv('TOKENTIMEOUT') ];
|
||||||
|
$model->update($id, $data);
|
||||||
// Set the new JWT in the response headers
|
|
||||||
// $response = service('response');
|
|
||||||
// $response->setHeader('Authorization', $newJwt);
|
|
||||||
return true;
|
return true;
|
||||||
}else{
|
}else{
|
||||||
|
$data =["token_time_out" => ''];
|
||||||
|
$model->update($id, $data);
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
http_response_code(401);
|
http_response_code(401);
|
||||||
$error = json_encode(["status" => 401, "message" => $data->message]);
|
// $error = json_encode(["status" => 401, "message" => $data->message]);
|
||||||
|
$error = json_encode(["status" => 401, "message" => "Token is Invalid"]);
|
||||||
echo $error;
|
echo $error;
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,27 +12,28 @@ use Firebase\JWT\SignatureInvalidException;
|
|||||||
use CodeIgniter\HTTP\RequestInterface;
|
use CodeIgniter\HTTP\RequestInterface;
|
||||||
use ReflectionClass;
|
use ReflectionClass;
|
||||||
|
|
||||||
|
use App\Models\EmployeeModel;
|
||||||
|
|
||||||
|
|
||||||
class JWTToken
|
class JWTToken
|
||||||
{
|
{
|
||||||
public static function encode($data =null)
|
public static function encode($data =null)
|
||||||
{
|
{
|
||||||
$secret_Key="secret";
|
$secret_Key ="secret";
|
||||||
$iat = time();
|
|
||||||
$exp = $iat + 180;
|
$request_data = (array)$data;
|
||||||
$request_data = [
|
|
||||||
"iat" => $iat,
|
|
||||||
"exp" => $exp,
|
|
||||||
];
|
|
||||||
if ($data !== null) {
|
|
||||||
$request_data = array_merge($request_data, (array)$data);
|
|
||||||
}
|
|
||||||
try{
|
try{
|
||||||
$token = JWT::encode($request_data ,$secret_Key,'HS512');
|
$token = JWT::encode($request_data ,$secret_Key,'HS512');
|
||||||
|
|
||||||
|
$model = new EmployeeModel();
|
||||||
|
$id = $request_data['id'];
|
||||||
|
$data =[
|
||||||
|
"token_time_out" => time() + getenv('TOKENTIMEOUT')
|
||||||
|
];
|
||||||
|
$model->update($id, $data);
|
||||||
|
|
||||||
return $token;
|
return $token;
|
||||||
// return ['status' => true,'token' => $token];
|
|
||||||
}
|
}
|
||||||
catch (Exception $e) {
|
catch (Exception $e) {
|
||||||
return ['status' => false,'message' => $e->getMessage()];
|
return ['status' => false,'message' => $e->getMessage()];
|
||||||
|
|||||||
@ -199,10 +199,13 @@ if(!function_exists('check_si'))
|
|||||||
|
|
||||||
if(!$is_si_found && $slab_value['si'] == $received_si) //match si amount
|
if(!$is_si_found && $slab_value['si'] == $received_si) //match si amount
|
||||||
{
|
{
|
||||||
|
// echo 'found';
|
||||||
$is_si_found = true;
|
$is_si_found = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check age slab
|
// check age slab
|
||||||
|
if(in_array(strtoupper($row['current_action']), ['I','A','DA']))
|
||||||
|
{
|
||||||
if($row[3] != null && DateTime::createFromFormat('d-M-Y', $row[3]) !== false)// dob
|
if($row[3] != null && DateTime::createFromFormat('d-M-Y', $row[3]) !== false)// dob
|
||||||
{
|
{
|
||||||
$dob = change_date_format($row[3],'d-M-Y','Y-m-d');
|
$dob = change_date_format($row[3],'d-M-Y','Y-m-d');
|
||||||
@ -225,10 +228,15 @@ if(!function_exists('check_si'))
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}//end of check age slab
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$is_age_slab_found = true;// send true if age conditin is not applicable
|
||||||
|
}//end of check age slab
|
||||||
|
}// end of for loop
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$is_si_found)
|
if(!$is_si_found)
|
||||||
|
|||||||
@ -38,7 +38,8 @@ class EmployeeModel extends Model
|
|||||||
"file_id",
|
"file_id",
|
||||||
"is_addon_value",
|
"is_addon_value",
|
||||||
"is_createdby_hr",
|
"is_createdby_hr",
|
||||||
"client_branch_id"
|
"client_branch_id",
|
||||||
|
"token_time_out"
|
||||||
];
|
];
|
||||||
|
|
||||||
// Callbacks
|
// Callbacks
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user