From 39cc5ef906c9a203034027550cb4dacd47ccf6fa Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Tue, 6 Mar 2018 19:39:34 +0100 Subject: [PATCH] [webpack.logout] now logout works --- build/api/core/AuthSystemDefault.php | 4 ++ build/api/module/casController.php | 2 +- public_html/asset/svg/remove.svg | 55 ++++++++++++++++++++++++++++ webpack/data/common.js | 5 +++ webpack/vue/menu.vue | 12 +++++- 5 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 public_html/asset/svg/remove.svg diff --git a/build/api/core/AuthSystemDefault.php b/build/api/core/AuthSystemDefault.php index f8125f2..edce675 100644 --- a/build/api/core/AuthSystemDefault.php +++ b/build/api/core/AuthSystemDefault.php @@ -63,6 +63,10 @@ if( $_SESSION['CAS']['admin'] === true ) $_SESSION['AUTH'][] = 'cas_admin'; + /* (2) Remove cas in AUTH */ + }else{ + $_SESSION['AUTH'] = \array_diff($_SESSION['AUTH'], ['cas_user']); + $_SESSION['AUTH'] = \array_diff($_SESSION['AUTH'], ['cas_admin']); } /* (2) Other permissions */ diff --git a/build/api/module/casController.php b/build/api/module/casController.php index 7b9e2f0..e38038e 100644 --- a/build/api/module/casController.php +++ b/build/api/module/casController.php @@ -129,7 +129,7 @@ class casController{ new \api\core\AuthSystemDefault(); /* (3) Return if logged out */ - return ['logged_out' => in_array('cas_user', $_SESSION['AUTH'])]; + return ['logged_out' => !in_array('cas_user', $_SESSION['AUTH'])]; } diff --git a/public_html/asset/svg/remove.svg b/public_html/asset/svg/remove.svg new file mode 100644 index 0000000..2845dae --- /dev/null +++ b/public_html/asset/svg/remove.svg @@ -0,0 +1,55 @@ + + + + + + image/svg+xml + + + + + + + + + diff --git a/webpack/data/common.js b/webpack/data/common.js index fce6dcd..4ba3139 100644 --- a/webpack/data/common.js +++ b/webpack/data/common.js @@ -64,3 +64,8 @@ if( gstore.get.URI.length > 0 && gstore.get.menu_item.hasOwnProperty(gstore.get. gstore.add('menu_item_active', gstore.get.menu_item[gstore.get.URI[0]].url); else gstore.add('menu_item_active', 'home'); + + +gstore.add('navigate', function(uri){ + console.log(uri); +}); \ No newline at end of file diff --git a/webpack/vue/menu.vue b/webpack/vue/menu.vue index 4c7a0b3..7d8b04d 100644 --- a/webpack/vue/menu.vue +++ b/webpack/vue/menu.vue @@ -22,7 +22,17 @@ export default { data(){ return { gstore: gstore.get }; }, methods: { navigate(uri){ - document.location = '/'+uri+'/'; + // if no logout -> redirect + if( uri !== 'logout' ){ + + document.location = '/'+uri+'/'; + return; + + } + + // logout call + api.call('DELETE cas', {}, function(rs){ document.location = '/'; }); + } } }