Refactor user permission handling to utilize hierarchy levels across user credential retrieval and role management. Update permission checks in user_roles.php and enhance session management in index.php for improved security and consistency.

This commit is contained in:
“VeLiTi”
2026-01-30 09:17:54 +01:00
parent 8df518d0a2
commit b3327f21ed
7 changed files with 19 additions and 11 deletions

View File

@@ -29,16 +29,23 @@ include_once dirname(__FILE__).'/settings/countries.php';
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//GET USER PERMISSION ASSIGNED
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
if (!isset($_SESSION['authorization']['id'])){
if (!isset($_SESSION['authorization']['id']) && isset($_SESSION['authorization']['userkey'])){
$api_url = '/v2/user_permissions/userkey='.$_SESSION['authorization']['userkey'];
$responses = ioServer($api_url,'');
//Decode Payload
if (!empty($responses)){$responses = json_decode($responses,true);}else{$responses = null;}
//STORE DATA IN SESSION
foreach($responses as $key => $value){
$_SESSION['authorization'][$key] = $value;
if (is_array($responses) && !isset($responses['error'])) {
foreach($responses as $key => $value){
$_SESSION['authorization'][$key] = $value;
}
} else {
// API call failed or returned error - redirect to login
session_destroy();
header('location: login.php');
die();
}
}