A free open source IT asset/license management system
Added session killer artisan command
snipe93d6ce1a6ad4
diff --git a/app/Console/Commands/KillAllSessions.php b/app/Console/Commands/KillAllSessions.phpnew file mode 100644index 0000000000..f3a8b22909--- /dev/null+++ b/app/Console/Commands/KillAllSessions.php@@ -0,0 +1,57 @@+<?php++namespace App\Console\Commands;++use Illuminate\Console\Command;++class KillAllSessions extends Command+{+ /**+ * The name and signature of the console command.+ *+ * @var string+ */+ protected $signature = 'snipeit:global-logout';++ /**+ * The console command description.+ *+ * @var string+ */+ protected $description = 'This command will destroy all web sessions on disk and will force a re-login for all users.';++ /**+ * Create a new command instance.+ *+ * @return void+ */+ public function __construct()+ {+ parent::__construct();+ }++ /**+ * Execute the console command.+ *+ * @return mixed+ */+ 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!');+ }+//+ }+}