From d046a298e12bc9243e17b733a193a35c3b7bf414 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sun, 19 Feb 2017 17:41:44 +0200 Subject: [PATCH] Add .env properties for REMEMBER_ME_ENABLED and AUTO_LOGOUT_SECONDS --- .env.example | 6 ++++++ docs/configure.rst | 7 +++++++ resources/views/auth/login.blade.php | 6 ++++-- resources/views/header.blade.php | 2 +- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/.env.example b/.env.example index 72f968b440..1ed1ec049c 100644 --- a/.env.example +++ b/.env.example @@ -54,6 +54,12 @@ FCM_API_TOKEN= GOOGLE_MAPS_ENABLED=true #GOOGLE_MAPS_API_KEY= +# Create a cookie to stay logged in +#REMEMBER_ME_ENABLED=true + +# The app automatically logs the user out after this number of seconds +#AUTO_LOGOUT_SECONDS=28800 + #S3_KEY= #S3_SECRET= #S3_REGION= diff --git a/docs/configure.rst b/docs/configure.rst index faad8578a8..7c48478ebd 100644 --- a/docs/configure.rst +++ b/docs/configure.rst @@ -86,6 +86,13 @@ If you need to set a list of trusted proxies you can add a TRUSTED_PROXIES value TRUSTED_PROXIES='10.0.0.0/8,172.16.0.0/12,192.168.0.0/16' +Stay logged in +"""""""""""""" + +By default the app clears the session when the browser is closed and automatically logs the user out after 8 hours. + +This can be modified by setting ``REMEMBER_ME_ENABLED`` and ``AUTO_LOGOUT_SECONDS`` in the .env file. + Customizations """""""""""""" diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php index 8340870124..6b48fadcaf 100644 --- a/resources/views/auth/login.blade.php +++ b/resources/views/auth/login.blade.php @@ -35,13 +35,15 @@ @endif - {{ Former::populateField('remember', 'true') }} + @if (env('REMEMBER_ME_ENABLED')) + {{ Former::populateField('remember', 'true') }} + {!! Former::hidden('remember')->raw() !!} + @endif
{!! Former::text('email')->placeholder(trans('texts.email_address'))->raw() !!} {!! Former::password('password')->placeholder(trans('texts.password'))->raw() !!}
- {!! Former::hidden('remember')->raw() !!} {!! Button::success(trans('texts.login')) ->withAttributes(['id' => 'loginButton', 'class' => 'green']) diff --git a/resources/views/header.blade.php b/resources/views/header.blade.php index 70eb372824..ab539316ef 100644 --- a/resources/views/header.blade.php +++ b/resources/views/header.blade.php @@ -228,7 +228,7 @@ // auto-logout after 8 hours window.setTimeout(function() { window.location = '{{ URL::to('/logout?reason=inactivity') }}'; - }, 1000 * 60 * 60 * 8); + }, {{ 1000 * env('AUTO_LOGOUT_SECONDS', (60 * 60 * 8)) }}); // auto-hide status alerts window.setTimeout(function() {