From 93d6ce1a6ad4336dca18f652bb87453a79b8e743 Mon Sep 17 00:00:00 2001 From: snipe Date: Thu, 10 Mar 2022 13:20:23 -0800 Subject: [PATCH 1/3] Added session killer artisan command Signed-off-by: snipe --- app/Console/Commands/KillAllSessions.php | 57 ++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 app/Console/Commands/KillAllSessions.php diff --git a/app/Console/Commands/KillAllSessions.php b/app/Console/Commands/KillAllSessions.php new file mode 100644 index 000000000..f3a8b2290 --- /dev/null +++ b/app/Console/Commands/KillAllSessions.php @@ -0,0 +1,57 @@ +confirm("\n****************************************************\nTHIS WILL FORCE A LOGIN FOR ALL LOGGED IN USERS.\n\nAre you SURE you wish to continue? ")) { + + $session_files = glob(storage_path("framework/sessions/*")); + + $count = 0; + foreach ($session_files as $file) { + + if (is_file($file)) + unlink($file); + $count++; + } + \DB::table('users')->update(['remember_token' => null]); + + $this->info($count. ' sessions cleared!'); + } +// + } +} From 3e3c277a3f27ef01bdd664489c85ad86f2f3360b Mon Sep 17 00:00:00 2001 From: snipe Date: Thu, 10 Mar 2022 13:29:52 -0800 Subject: [PATCH 2/3] Better phrasing Signed-off-by: snipe --- app/Console/Commands/RestoreFromBackup.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Console/Commands/RestoreFromBackup.php b/app/Console/Commands/RestoreFromBackup.php index 06c99ec08..0cc4a9a26 100644 --- a/app/Console/Commands/RestoreFromBackup.php +++ b/app/Console/Commands/RestoreFromBackup.php @@ -14,7 +14,7 @@ class RestoreFromBackup extends Command * @var string */ protected $signature = 'snipeit:restore - {--force : Skip the danger prompt; assuming you hit "y"} + {--force : Skip the danger prompt; assuming you enter "y"} {filename : The zip file to be migrated} {--no-progress : Don\'t show a progress bar}'; From 1ac293a12a1be1b42210b3428bdbcb0e4db607d5 Mon Sep 17 00:00:00 2001 From: snipe Date: Thu, 10 Mar 2022 13:30:03 -0800 Subject: [PATCH 3/3] Add a force override Signed-off-by: snipe --- app/Console/Commands/KillAllSessions.php | 32 +++++++++++++----------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/app/Console/Commands/KillAllSessions.php b/app/Console/Commands/KillAllSessions.php index f3a8b2290..043be0fa1 100644 --- a/app/Console/Commands/KillAllSessions.php +++ b/app/Console/Commands/KillAllSessions.php @@ -11,7 +11,7 @@ class KillAllSessions extends Command * * @var string */ - protected $signature = 'snipeit:global-logout'; + protected $signature = 'snipeit:global-logout {--force : Skip the danger prompt; assuming you enter "y"} '; /** * The console command description. @@ -37,21 +37,23 @@ class KillAllSessions extends Command */ public function handle() { - if ($this->confirm("\n****************************************************\nTHIS WILL FORCE A LOGIN FOR ALL LOGGED IN USERS.\n\nAre you SURE you wish to continue? ")) { - $session_files = glob(storage_path("framework/sessions/*")); - - $count = 0; - foreach ($session_files as $file) { - - if (is_file($file)) - unlink($file); - $count++; - } - \DB::table('users')->update(['remember_token' => null]); - - $this->info($count. ' sessions cleared!'); + if (!$this->option('force') && !$this->confirm("****************************************************\nTHIS WILL FORCE A LOGIN FOR ALL LOGGED IN USERS.\n\nAre you SURE you wish to continue? ")) { + return $this->error("Session loss not confirmed"); } -// + + $session_files = glob(storage_path("framework/sessions/*")); + + $count = 0; + foreach ($session_files as $file) { + + if (is_file($file)) + unlink($file); + $count++; + } + \DB::table('users')->update(['remember_token' => null]); + + $this->info($count. ' sessions cleared!'); + } }