From f856b67f7e21d6ab30919d14a5d399371c3b95da Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Fri, 8 Dec 2017 00:32:18 +0100 Subject: [PATCH] BIG FIX: session_name with logout .... --- build/api/core/AuthSystemDefault.php | 12 +++++++----- build/api/module/admin.php | 7 +++++++ build/api/module/user.php | 7 +++++++ build/router/controller/page.php | 4 +++- config/modules.json | 14 ++++++++++++++ 5 files changed, 38 insertions(+), 6 deletions(-) diff --git a/build/api/core/AuthSystemDefault.php b/build/api/core/AuthSystemDefault.php index 6cf30e9..ff960e7 100755 --- a/build/api/core/AuthSystemDefault.php +++ b/build/api/core/AuthSystemDefault.php @@ -25,11 +25,13 @@ public static function check(){ /* (1) Initialisation ---------------------------------------------------------*/ - if( !isset($_SESSION['TOKEN']) ) $_SESSION['TOKEN'] = []; - if( !isset($_SESSION['AUTH']) ) $_SESSION['AUTH'] = []; - if( !isset($_SESSION['PERM']) ) $_SESSION['PERM'] = []; - if( !isset($_SESSION['USER']) ) $_SESSION['USER'] = []; - if( !isset($_SESSION['ADMIN']) ) $_SESSION['ADMIN'] = []; + if( !isset($_SESSION['TOKEN']) ) $_SESSION['TOKEN'] = []; + if( !isset($_SESSION['AUTH']) ) $_SESSION['AUTH'] = []; + if( !isset($_SESSION['PERM']) ) $_SESSION['PERM'] = []; + if( !isset($_SESSION['USER']) ) $_SESSION['USER'] = []; + if( !isset($_SESSION['ADMIN']) ) $_SESSION['ADMIN'] = []; + if( !isset($_SESSION['NAME']) ) $_SESSION['NAME'] = ''; + if( !isset($_SESSION['WS']) ) $_SESSION['WS'] = true; /* (2) Gestion de AUTH (authentification) diff --git a/build/api/module/admin.php b/build/api/module/admin.php index 9cd5da0..d6d55ec 100644 --- a/build/api/module/admin.php +++ b/build/api/module/admin.php @@ -52,6 +52,7 @@ class admin{ ---------------------------------------------------------*/ /* (1) Update session */ $_SESSION['TOKEN'] = 'a'.$fetched_admin['token']; + $_SESSION['WS'] = true; // to tell websocket we are connected new AuthSystemDefault; /* (2) Return status */ @@ -105,4 +106,10 @@ class admin{ } + + + public function DELETE_logout(){ + $_SESSION = []; + } + } diff --git a/build/api/module/user.php b/build/api/module/user.php index 01b093b..3f85785 100644 --- a/build/api/module/user.php +++ b/build/api/module/user.php @@ -52,6 +52,7 @@ class user{ ---------------------------------------------------------*/ /* (1) Update session */ $_SESSION['TOKEN'] = 'u'.$fetched_user['token']; + $_SESSION['WS'] = true; // to tell websocket we are connected new AuthSystemDefault; /* (2) Return status */ @@ -104,4 +105,10 @@ class user{ } + + + public function DELETE_logout(){ + $_SESSION = []; + } + } diff --git a/build/router/controller/page.php b/build/router/controller/page.php index ac1668c..d27051e 100755 --- a/build/router/controller/page.php +++ b/build/router/controller/page.php @@ -27,7 +27,7 @@ */ public function load(){ - if( !isset($_SESSION['NAME']) || strlen($_SESSION['NAME']) == 0 ){ + if( $_SESSION['WS'] || strlen($_SESSION['NAME']) == 0 ){ // ask with websocketInterop $wsi = new wsinterop('localhost', 9998); @@ -63,6 +63,8 @@ $wsi->close(); $wsi = null; + $_SESSION['WS'] = false; + } if( file_exists(__ROOT__."/view/home.php") ) include __ROOT__."/view/home.php"; diff --git a/config/modules.json b/config/modules.json index 354df6a..d10214e 100755 --- a/config/modules.json +++ b/config/modules.json @@ -25,6 +25,13 @@ "output": { "registered": { "description": "UID du nouvel administrateur", "type": "id" } } + }, + + "DELETE logout": { + "description": "Déconnexion utilisateur", + "permissions": [], + "parameters": {}, + "output": {} } }, @@ -56,6 +63,13 @@ "output": { "registered": { "description": "UID du nouvel utilisateur", "type": "id" } } + }, + + "DELETE logout": { + "description": "Déconnexion utilisateur", + "permissions": [], + "parameters": {}, + "output": {} } },