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()
|
public function keepAlive()
|
||||||
{
|
{
|
||||||
return Auth::check() ? RESULT_SUCCESS : RESULT_FAILURE;
|
return RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
<?php namespace App\Http\Controllers;
|
<?php namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App;
|
|
||||||
use Auth;
|
use Auth;
|
||||||
use Session;
|
use Session;
|
||||||
use Utils;
|
use Utils;
|
||||||
@ -81,7 +80,7 @@ class InvoiceController extends BaseController
|
|||||||
{
|
{
|
||||||
$invitationKey = Session::get('invitation_key');
|
$invitationKey = Session::get('invitation_key');
|
||||||
if (!$invitationKey) {
|
if (!$invitationKey) {
|
||||||
return Redirect::to('/setup');
|
app()->abort(404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$invitation = Invitation::with('account')->where('invitation_key', '=', $invitationKey)->first();
|
$invitation = Invitation::with('account')->where('invitation_key', '=', $invitationKey)->first();
|
||||||
@ -109,7 +108,6 @@ class InvoiceController extends BaseController
|
|||||||
|
|
||||||
public function getClientDatatable()
|
public function getClientDatatable()
|
||||||
{
|
{
|
||||||
//$accountId = Auth::user()->account_id;
|
|
||||||
$search = Input::get('sSearch');
|
$search = Input::get('sSearch');
|
||||||
$invitationKey = Session::get('invitation_key');
|
$invitationKey = Session::get('invitation_key');
|
||||||
$invitation = Invitation::where('invitation_key', '=', $invitationKey)->first();
|
$invitation = Invitation::where('invitation_key', '=', $invitationKey)->first();
|
||||||
@ -177,13 +175,13 @@ class InvoiceController extends BaseController
|
|||||||
$invitation = Invitation::where('invitation_key', '=', $invitationKey)->first();
|
$invitation = Invitation::where('invitation_key', '=', $invitationKey)->first();
|
||||||
|
|
||||||
if (!$invitation) {
|
if (!$invitation) {
|
||||||
App::abort(404, trans('texts.invoice_not_found'));
|
app()->abort(404, trans('texts.invoice_not_found'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$invoice = $invitation->invoice;
|
$invoice = $invitation->invoice;
|
||||||
|
|
||||||
if (!$invoice || $invoice->is_deleted) {
|
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');
|
$invoice->load('user', 'invoice_items', 'invoice_design', 'account.country', 'client.contacts', 'client.country');
|
||||||
@ -191,7 +189,7 @@ class InvoiceController extends BaseController
|
|||||||
$account = $client->account;
|
$account = $client->account;
|
||||||
|
|
||||||
if (!$client || $client->is_deleted) {
|
if (!$client || $client->is_deleted) {
|
||||||
App::abort(404, trans('texts.invoice_not_found'));
|
app()->abort(404, trans('texts.invoice_not_found'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($account->subdomain) {
|
if ($account->subdomain) {
|
||||||
|
@ -51,7 +51,7 @@ class PaymentController extends BaseController
|
|||||||
{
|
{
|
||||||
$invitationKey = Session::get('invitation_key');
|
$invitationKey = Session::get('invitation_key');
|
||||||
if (!$invitationKey) {
|
if (!$invitationKey) {
|
||||||
return Redirect::to('/setup');
|
app()->abort(404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$invitation = Invitation::with('account')->where('invitation_key', '=', $invitationKey)->first();
|
$invitation = Invitation::with('account')->where('invitation_key', '=', $invitationKey)->first();
|
||||||
|
@ -71,7 +71,7 @@ class QuoteController extends BaseController
|
|||||||
{
|
{
|
||||||
$invitationKey = Session::get('invitation_key');
|
$invitationKey = Session::get('invitation_key');
|
||||||
if (!$invitationKey) {
|
if (!$invitationKey) {
|
||||||
return Redirect::to('/setup');
|
app()->abort(404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$invitation = Invitation::with('account')->where('invitation_key', '=', $invitationKey)->first();
|
$invitation = Invitation::with('account')->where('invitation_key', '=', $invitationKey)->first();
|
||||||
|
@ -169,6 +169,7 @@ class ContactMailer extends Mailer
|
|||||||
'$client' => $data['client']->getDisplayName(),
|
'$client' => $data['client']->getDisplayName(),
|
||||||
'$account' => $data['account']->getDisplayName(),
|
'$account' => $data['account']->getDisplayName(),
|
||||||
'$contact' => $data['invitation']->contact->getDisplayName(),
|
'$contact' => $data['invitation']->contact->getDisplayName(),
|
||||||
|
'$firstName' => $data['invitation']->contact->first_name,
|
||||||
'$amount' => Utils::formatMoney($data['amount'], $data['client']->getCurrencyId()),
|
'$amount' => Utils::formatMoney($data['amount'], $data['client']->getCurrencyId()),
|
||||||
'$invoice' => $data['invitation']->invoice->invoice_number,
|
'$invoice' => $data['invitation']->invoice->invoice_number,
|
||||||
'$quote' => $data['invitation']->invoice->invoice_number,
|
'$quote' => $data['invitation']->invoice->invoice_number,
|
||||||
|
@ -145,6 +145,7 @@
|
|||||||
'amount',
|
'amount',
|
||||||
'link',
|
'link',
|
||||||
'contact',
|
'contact',
|
||||||
|
'firstName',
|
||||||
'invoice',
|
'invoice',
|
||||||
'quote'
|
'quote'
|
||||||
];
|
];
|
||||||
@ -156,6 +157,7 @@
|
|||||||
formatMoney(100),
|
formatMoney(100),
|
||||||
"{{ Auth::user()->account->getSiteUrl() . '...' }}",
|
"{{ Auth::user()->account->getSiteUrl() . '...' }}",
|
||||||
"Contact Name",
|
"Contact Name",
|
||||||
|
"First Name",
|
||||||
"0001",
|
"0001",
|
||||||
"0001"
|
"0001"
|
||||||
];
|
];
|
||||||
|
@ -235,36 +235,7 @@
|
|||||||
@endif
|
@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() {
|
$(function() {
|
||||||
startWarnSessionTimeout();
|
|
||||||
|
|
||||||
window.setTimeout(function() {
|
window.setTimeout(function() {
|
||||||
$(".alert-hide").fadeOut();
|
$(".alert-hide").fadeOut();
|
||||||
}, 3000);
|
}, 3000);
|
||||||
@ -495,14 +466,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<br/>
|
<br/>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
||||||
<div class="alert alert-warning" id="keepAliveDiv" style="display:none">
|
@include('partials.warn_session', ['redirectTo' => '/dashboard'])
|
||||||
{!! trans('texts.page_expire', ['click_here' => link_to('#', trans('texts.click_here'), ['onclick' => 'keepAlive()'])]) !!}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
@if (Session::has('warning'))
|
@if (Session::has('warning'))
|
||||||
<div class="alert alert-warning">{!! Session::get('warning') !!}</div>
|
<div class="alert alert-warning">{!! Session::get('warning') !!}</div>
|
||||||
|
@ -108,12 +108,13 @@
|
|||||||
function trackEvent(category, action) {}
|
function trackEvent(category, action) {}
|
||||||
</script>
|
</script>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@yield('body')
|
@yield('body')
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
NINJA.formIsChanged = {{ isset($formIsChanged) && $formIsChanged ? 'true' : 'false' }};
|
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() {
|
$('form.warn-on-exit input, form.warn-on-exit textarea, form.warn-on-exit select').change(function() {
|
||||||
NINJA.formIsChanged = true;
|
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>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
||||||
|
@include('partials.warn_session', ['redirectTo' => '/'])
|
||||||
|
|
||||||
@if (Session::has('warning'))
|
@if (Session::has('warning'))
|
||||||
<div class="alert alert-warning">{!! Session::get('warning') !!}</div>
|
<div class="alert alert-warning">{!! Session::get('warning') !!}</div>
|
||||||
@endif
|
@endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user