From 6371339805d599ee07066425ea1f645c1efef699 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Tue, 31 Jan 2017 13:09:25 +0200 Subject: [PATCH] Auto logout after inactivity --- app/Http/Controllers/Auth/AuthController.php | 4 ++++ resources/lang/en/texts.php | 2 ++ resources/views/header.blade.php | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/app/Http/Controllers/Auth/AuthController.php b/app/Http/Controllers/Auth/AuthController.php index 10976a249997..c5fbccb78790 100644 --- a/app/Http/Controllers/Auth/AuthController.php +++ b/app/Http/Controllers/Auth/AuthController.php @@ -186,6 +186,10 @@ class AuthController extends Controller Session::flush(); + if ($reason = request()->reason) { + Session::flash('warning', trans("texts.{$reason}_logout")); + } + return $response; } } diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 602bc6eb2cae..8ca03297ce5a 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -2344,6 +2344,8 @@ $LANG = array( 'view_statement' => 'View Statement', 'statement' => 'Statement', 'statement_date' => 'Statement Date', + 'inactivity_logout' => 'Due to inactivity, you have been automatically logged out.', + ); return $LANG; diff --git a/resources/views/header.blade.php b/resources/views/header.blade.php index 18d34b339f42..62576029dec1 100644 --- a/resources/views/header.blade.php +++ b/resources/views/header.blade.php @@ -225,6 +225,12 @@ } $(function() { + // auto-logout after 8 hours + window.setTimeout(function() { + window.location = '{{ URL::to('/logout?reason=inactivity') }}'; + }, 1000 * 60 * 60 * 8); + + // auto-hide status alerts window.setTimeout(function() { $(".alert-hide").fadeOut(); }, 3000);