1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-09 20:52:56 +01:00

Store that invoice was authorized in the session #1230

This commit is contained in:
Hillel Coren 2017-01-02 14:47:39 +02:00
parent c2171e5f4f
commit 9b13321a7f
4 changed files with 24 additions and 15 deletions

View File

@ -209,9 +209,13 @@ class ClientPortalController extends BaseController
return RESULT_FAILURE;
}
$invitation->signature_base64 = Input::get('signature');
$invitation->signature_date = date_create();
$invitation->save();
if ($signature = Input::get('signature')) {
$invitation->signature_base64 = $signature;
$invitation->signature_date = date_create();
$invitation->save();
}
session(['authorized:' . $invitation->invitation_key => true]);
return RESULT_SUCCESS;
}

View File

@ -77,6 +77,11 @@ class OnlinePaymentController extends BaseController
$invitation = $invitation->load('invoice.client.account.account_gateways.gateway');
$account = $invitation->account;
if ($account->requiresAuthorization($invitation->invoice) && ! session('authorized:' . $invitation->invitation_key)) {
return redirect()->to('view/' . $invitation->invitation_key);
}
$account->loadLocalizationSettings($invitation->invoice->client);
if ( ! $gatewayTypeAlias) {

View File

@ -1881,7 +1881,7 @@ class Account extends Eloquent
return $this->enabled_modules & static::$modules[$entityType];
}
public function showAuthenticatePanel($invoice)
public function requiresAuthorization($invoice)
{
return $this->showAcceptTerms($invoice) || $this->showSignature($invoice);
}

View File

@ -203,7 +203,7 @@
refreshPDF();
@endif
@if ($account->showAuthenticatePanel($invoice))
@if ($account->requiresAuthorization($invoice))
$('#paymentButtons a').on('click', function(e) {
e.preventDefault();
window.pendingPaymentHref = $(this).attr('href');
@ -246,17 +246,17 @@
var data = {
signature: $('#signature').jSignature('getData', 'svgbase64')[1]
};
$.ajax({
url: "{{ URL::to('sign/' . $invitation->invitation_key) }}",
type: 'PUT',
data: data,
success: function(response) {
redirectToPayment();
}
});
@else
redirectToPayment();
var data = false;
@endif
$.ajax({
url: "{{ URL::to('sign/' . $invitation->invitation_key) }}",
type: 'PUT',
data: data,
success: function(response) {
redirectToPayment();
}
});
}
function redirectToPayment() {
@ -313,7 +313,7 @@
</div>
@endif
@if ($account->showAuthenticatePanel($invoice))
@if ($account->requiresAuthorization($invoice))
<div class="modal fade" id="authenticationModal" tabindex="-1" role="dialog" aria-labelledby="authenticationModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">