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:
“VeLiTi”
2026-01-19 15:29:16 +01:00
parent 782050c3ca
commit 24481279d5
99 changed files with 683 additions and 539 deletions

View File

@@ -1,7 +1,7 @@
<?php
defined(page_security_key) or exit;
if (debug && debug_id == $_SESSION['id']){
if (debug && debug_id == $_SESSION['authorization']['id']){
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);
@@ -9,11 +9,11 @@ if (debug && debug_id == $_SESSION['id']){
$page = 'softwaretool';
//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;
}
$bearertoken = createCommunicationToken($_SESSION['userkey']);
$bearertoken = createCommunicationToken($_SESSION['authorization']['userkey']);
//+++++++++++++++++++++++++++++++++++++++++++++++++++++
// PAYMENT RETURN DETECTION
@@ -201,7 +201,7 @@ if (isset($_GET['equipmentID'])){$returnpage = 'equipment&equipmentID='.$_GET['e
//SHOW BACK BUTTON ONLY FOR PORTAL USERS
if (isAllowed('dashboard',$_SESSION['profile'],$_SESSION['permission'],'R') != 0){
if (isAllowed('dashboard',$_SESSION['authorization']['profile'],$_SESSION['authorization']['permission'],'R') != 0){
$view .= '
<div class="title-actions">
<a href="index.php?page='.$returnpage.'" class="btn alt mar-right-2"><i class="fa-solid fa-arrow-left"></i></a>