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:
@@ -32,12 +32,10 @@ if (isset($_POST['register'])){
|
||||
$register = $_POST;
|
||||
//GET USERKEY
|
||||
$data = json_encode(array("username" => interface_user, "password" => interface_pw), JSON_UNESCAPED_UNICODE);
|
||||
//Secure data
|
||||
$payload = generate_payload($data);
|
||||
//API call
|
||||
$responses = ioServer('/v1/authorization', $payload);
|
||||
$responses = ioServer('/v2/authorization', $data);
|
||||
//Decode Payload
|
||||
if (!empty($responses)){$responses = decode_payload($responses);}else{$responses = '400';}
|
||||
if (!empty($responses)){$responses = json_decode($responses,true);}else{$responses = '400';}
|
||||
|
||||
if ($responses === 'NOK' || $responses === '400'){
|
||||
//Not allowed
|
||||
@@ -47,7 +45,7 @@ if (isset($_POST['register'])){
|
||||
// Start a new session
|
||||
session_start();
|
||||
// Store data in session
|
||||
$_SESSION['userkey'] = $responses->userkey;
|
||||
$_SESSION['authorization']['userkey'] = $responses['userkey'];
|
||||
// GET ALL POST DATA
|
||||
$data = json_encode($register, JSON_UNESCAPED_UNICODE);
|
||||
// Secure data
|
||||
|
||||
Reference in New Issue
Block a user