Refactor user session handling and permissions management
- Updated session variables to use 'authorization' array instead of 'username' for user identification across multiple files. - Introduced a new function `getUserPermissions` to consolidate user permissions retrieval based on assigned roles. - Modified API calls to use the new authorization structure and updated endpoints to v2. - Enhanced language support by adding 'PL' to the list of supported languages. - Cleaned up redundant code and improved session management during user login and registration processes. - Added a new API endpoint for fetching user permissions based on user ID.
This commit is contained in:
@@ -3,19 +3,19 @@ defined(page_security_key) or exit;
|
||||
|
||||
$page = 'maintenance';
|
||||
//Check if allowed
|
||||
if (isAllowed($page,$_SESSION['profile'],$_SESSION['permission'],'R') === 0){
|
||||
if (isAllowed($page,$_SESSION['authorization']['profile'],$_SESSION['authorization']['permission'],'R') === 0){
|
||||
header('location: index.php');
|
||||
exit;
|
||||
}
|
||||
//PAGE Security
|
||||
$update_allowed = isAllowed($page ,$_SESSION['profile'],$_SESSION['permission'],'U');
|
||||
$delete_allowed = isAllowed($page ,$_SESSION['profile'],$_SESSION['permission'],'D');
|
||||
$create_allowed = isAllowed($page ,$_SESSION['profile'],$_SESSION['permission'],'C');
|
||||
$update_allowed = isAllowed($page ,$_SESSION['authorization']['profile'],$_SESSION['authorization']['permission'],'U');
|
||||
$delete_allowed = isAllowed($page ,$_SESSION['authorization']['profile'],$_SESSION['authorization']['permission'],'D');
|
||||
$create_allowed = isAllowed($page ,$_SESSION['authorization']['profile'],$_SESSION['authorization']['permission'],'C');
|
||||
|
||||
if ($update_allowed === 1){
|
||||
if (isset($_POST['geoupdate'])){
|
||||
//GEOLOCATION UPDATE
|
||||
geolocationUpdate($_SESSION['userkey']);
|
||||
geolocationUpdate($_SESSION['authorization']['userkey']);
|
||||
}
|
||||
|
||||
if (isset($_POST['closeContract'])){
|
||||
@@ -29,19 +29,19 @@ if ($update_allowed === 1){
|
||||
if (isset($_POST['updateproductmeusurements'])){
|
||||
$total_measurement = traintotalMeasurement();
|
||||
$total_results = statisticalAnalyses($total_measurement);
|
||||
storeMeasurementProduct($total_results, $_SESSION['userkey']);
|
||||
storeMeasurementProduct($total_results, $_SESSION['authorization']['userkey']);
|
||||
}
|
||||
if (isset($_POST['updateequipmentmeusurements'])){
|
||||
storeMeasurementEquipment('');
|
||||
}
|
||||
if (isset($_POST['generatefile'])){
|
||||
generateLanguageFile($_POST['language'],$_SESSION['userkey']);
|
||||
generateLanguageFile($_POST['language'],$_SESSION['authorization']['userkey']);
|
||||
}
|
||||
if (isset($_POST['generateDealerInformation'])){
|
||||
generateDealerInformation($_SESSION['userkey']);
|
||||
generateDealerInformation($_SESSION['authorization']['userkey']);
|
||||
}
|
||||
if (isset($_POST['generateCountriesFile'])){
|
||||
generateCountriesFile($_SESSION['userkey']);
|
||||
generateCountriesFile($_SESSION['authorization']['userkey']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user