mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Added warning when form token is about to expire
This commit is contained in:
parent
69034c6d71
commit
f8b449a471
@ -98,6 +98,6 @@ class HomeController extends BaseController
|
||||
|
||||
public function keepAlive()
|
||||
{
|
||||
return Auth::check() ? RESULT_SUCCESS : RESULT_FAILURE;
|
||||
return RESULT_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use App;
|
||||
use Auth;
|
||||
use Session;
|
||||
use Utils;
|
||||
@ -81,7 +80,7 @@ class InvoiceController extends BaseController
|
||||
{
|
||||
$invitationKey = Session::get('invitation_key');
|
||||
if (!$invitationKey) {
|
||||
return Redirect::to('/setup');
|
||||
app()->abort(404);
|
||||
}
|
||||
|
||||
$invitation = Invitation::with('account')->where('invitation_key', '=', $invitationKey)->first();
|
||||
@ -109,7 +108,6 @@ class InvoiceController extends BaseController
|
||||
|
||||
public function getClientDatatable()
|
||||
{
|
||||
//$accountId = Auth::user()->account_id;
|
||||
$search = Input::get('sSearch');
|
||||
$invitationKey = Session::get('invitation_key');
|
||||
$invitation = Invitation::where('invitation_key', '=', $invitationKey)->first();
|
||||
@ -177,13 +175,13 @@ class InvoiceController extends BaseController
|
||||
$invitation = Invitation::where('invitation_key', '=', $invitationKey)->first();
|
||||
|
||||
if (!$invitation) {
|
||||
App::abort(404, trans('texts.invoice_not_found'));
|
||||
app()->abort(404, trans('texts.invoice_not_found'));
|
||||
}
|
||||
|
||||
$invoice = $invitation->invoice;
|
||||
|
||||
if (!$invoice || $invoice->is_deleted) {
|
||||
App::abort(404, trans('texts.invoice_not_found'));
|
||||
app()->abort(404, trans('texts.invoice_not_found'));
|
||||
}
|
||||
|
||||
$invoice->load('user', 'invoice_items', 'invoice_design', 'account.country', 'client.contacts', 'client.country');
|
||||
@ -191,7 +189,7 @@ class InvoiceController extends BaseController
|
||||
$account = $client->account;
|
||||
|
||||
if (!$client || $client->is_deleted) {
|
||||
App::abort(404, trans('texts.invoice_not_found'));
|
||||
app()->abort(404, trans('texts.invoice_not_found'));
|
||||
}
|
||||
|
||||
if ($account->subdomain) {
|
||||
|
@ -51,7 +51,7 @@ class PaymentController extends BaseController
|
||||
{
|
||||
$invitationKey = Session::get('invitation_key');
|
||||
if (!$invitationKey) {
|
||||
return Redirect::to('/setup');
|
||||
app()->abort(404);
|
||||
}
|
||||
|
||||
$invitation = Invitation::with('account')->where('invitation_key', '=', $invitationKey)->first();
|
||||
|
@ -71,7 +71,7 @@ class QuoteController extends BaseController
|
||||
{
|
||||
$invitationKey = Session::get('invitation_key');
|
||||
if (!$invitationKey) {
|
||||
return Redirect::to('/setup');
|
||||
app()->abort(404);
|
||||
}
|
||||
|
||||
$invitation = Invitation::with('account')->where('invitation_key', '=', $invitationKey)->first();
|
||||
|
@ -169,6 +169,7 @@ class ContactMailer extends Mailer
|
||||
'$client' => $data['client']->getDisplayName(),
|
||||
'$account' => $data['account']->getDisplayName(),
|
||||
'$contact' => $data['invitation']->contact->getDisplayName(),
|
||||
'$firstName' => $data['invitation']->contact->first_name,
|
||||
'$amount' => Utils::formatMoney($data['amount'], $data['client']->getCurrencyId()),
|
||||
'$invoice' => $data['invitation']->invoice->invoice_number,
|
||||
'$quote' => $data['invitation']->invoice->invoice_number,
|
||||
|
@ -145,6 +145,7 @@
|
||||
'amount',
|
||||
'link',
|
||||
'contact',
|
||||
'firstName',
|
||||
'invoice',
|
||||
'quote'
|
||||
];
|
||||
@ -156,6 +157,7 @@
|
||||
formatMoney(100),
|
||||
"{{ Auth::user()->account->getSiteUrl() . '...' }}",
|
||||
"Contact Name",
|
||||
"First Name",
|
||||
"0001",
|
||||
"0001"
|
||||
];
|
||||
|
@ -235,36 +235,7 @@
|
||||
@endif
|
||||
}
|
||||
|
||||
|
||||
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() {
|
||||
clearTimeout(redirectTimer);
|
||||
$('#keepAliveDiv').fadeOut();
|
||||
$.get('{{ URL::to('/keep_alive') }}');
|
||||
startWarnSessionTimeout();
|
||||
}
|
||||
|
||||
$(function() {
|
||||
startWarnSessionTimeout();
|
||||
|
||||
window.setTimeout(function() {
|
||||
$(".alert-hide").fadeOut();
|
||||
}, 3000);
|
||||
@ -495,14 +466,10 @@
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
|
||||
|
||||
<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>
|
||||
<div class="container">
|
||||
|
||||
@include('partials.warn_session', ['redirectTo' => '/dashboard'])
|
||||
|
||||
@if (Session::has('warning'))
|
||||
<div class="alert alert-warning">{!! Session::get('warning') !!}</div>
|
||||
|
@ -108,12 +108,13 @@
|
||||
function trackEvent(category, action) {}
|
||||
</script>
|
||||
@endif
|
||||
|
||||
|
||||
@yield('body')
|
||||
|
||||
<script type="text/javascript">
|
||||
NINJA.formIsChanged = {{ isset($formIsChanged) && $formIsChanged ? 'true' : 'false' }};
|
||||
$(function() {
|
||||
|
||||
$(function() {
|
||||
$('form.warn-on-exit input, form.warn-on-exit textarea, form.warn-on-exit select').change(function() {
|
||||
NINJA.formIsChanged = true;
|
||||
});
|
||||
|
39
resources/views/partials/warn_session.blade.php
Normal file
39
resources/views/partials/warn_session.blade.php
Normal file
@ -0,0 +1,39 @@
|
||||
<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>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
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($redirectTo) }}';
|
||||
}, 1000 * 60);
|
||||
}
|
||||
|
||||
// keep the token cookie valid to prevent token mismatch errors
|
||||
function keepAlive() {
|
||||
clearTimeout(redirectTimer);
|
||||
$('#keepAliveDiv').fadeOut();
|
||||
$.get('{{ URL::to('/keep_alive') }}');
|
||||
startWarnSessionTimeout();
|
||||
}
|
||||
|
||||
$(function() {
|
||||
if ($('form.warn-on-exit').length > 0) {
|
||||
startWarnSessionTimeout();
|
||||
}
|
||||
});
|
||||
</script>
|
@ -199,8 +199,10 @@ table.table thead .sorting_desc_disabled:after { content: '' !important }
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
|
||||
<div class="container">
|
||||
|
||||
@include('partials.warn_session', ['redirectTo' => '/'])
|
||||
|
||||
@if (Session::has('warning'))
|
||||
<div class="alert alert-warning">{!! Session::get('warning') !!}</div>
|
||||
@endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user