1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-18 00:53:10 +01:00

Working on session warning

This commit is contained in:
Hillel Coren 2015-09-27 00:08:59 +03:00
parent 902f8948b0
commit 8337bc9669
4 changed files with 36 additions and 14 deletions

View File

@ -1,7 +1,6 @@
<?php namespace App\Http\Controllers;
use Response;
use Request;
use Redirect;
use Auth;
use View;
@ -99,6 +98,6 @@ class HomeController extends BaseController
public function keepAlive()
{
return RESULT_SUCCESS;
return Auth::check() ? RESULT_SUCCESS : RESULT_FAILURE;
}
}

View File

@ -29,7 +29,7 @@ return [
|
*/
'lifetime' => env('SESSION_LIFETIME', 1),
'lifetime' => env('SESSION_LIFETIME', 120),
'expire_on_close' => false,

View File

@ -791,5 +791,7 @@ return array(
'referral_code' => 'Referral Code',
'last_sent_on' => 'Last sent on :date',
'page_expire' => 'This page will expire soon, :click_here to keep working',
);

View File

@ -236,20 +236,37 @@
}
var redirectTimer = null;
function startWarnSessionTimeout() {
var oneMinute = 1000 * 60;
var twoMinutes = oneMinute * 2;
var twoHours = oneMinute * 120;
setTimeout(function() {
warnSessionExpring();
}, (twoHours - twoMinutes));
}
function warnSessionExpring() {
$("#keepAliveDiv").fadeIn();
redirectTimer = setTimeout(function() {
NINJA.formIsChanged = false;
window.location = '{{ URL::to('/dashboard') }}';
}, 1000 * 60);
}
// keep the token cookie valid to prevent token mismatch errors
function keepAlive() {
window.setTimeout(function() {
$.get('{{ URL::to('/keep_alive') }}', function(data) {
keepAlive();
})
}, 1000 * 60 * 60);
clearTimeout(redirectTimer);
$('#keepAliveDiv').fadeOut();
$.get('{{ URL::to('/keep_alive') }}');
startWarnSessionTimeout();
}
$(function() {
keepAlive();
startWarnSessionTimeout();
window.setTimeout(function() {
$(".alert-hide").fadeOut(500);
$(".alert-hide").fadeOut();
}, 3000);
$('#search').blur(function(){
@ -483,6 +500,10 @@
<br/>
<div class="container">
<div class="alert alert-warning" id="keepAliveDiv" style="display:none">
{!! trans('texts.page_expire', ['click_here' => link_to('#', trans('texts.click_here'), ['onclick' => 'keepAlive()'])]) !!}
</div>
@if (Session::has('warning'))
<div class="alert alert-warning">{!! Session::get('warning') !!}</div>
@endif
@ -499,11 +520,11 @@
@endif
@if (Session::has('error'))
<div class="alert alert-danger">{!! Session::get('error') !!}</div>
<div class="alert alert-danger">{!! Session::get('error') !!}</div>
@endif
@if (!isset($showBreadcrumbs) || $showBreadcrumbs)
{!! HTML::breadcrumbs() !!}
{!! HTML::breadcrumbs() !!}
@endif
@yield('content')