Skip to content

Commit

Permalink
[JS] add: signature action missing token
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-eoxia committed Apr 29, 2022
1 parent 08fc5ed commit 3e564e9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions core/tpl/digiriskdolibarr_signature_view.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<?php endif; ?>

<div class="modal-signature" value="<?php echo $element->id ?>">
<input type="hidden" name="token" value="<?php echo newToken(); ?>">
<div class="wpeo-modal modal-signature" id="modal-signature<?php echo $element->id ?>">
<div class="modal-container wpeo-modal-event">
<!-- Modal-Header-->
Expand Down
11 changes: 7 additions & 4 deletions js/digiriskdolibarr.js.php
Original file line number Diff line number Diff line change
Expand Up @@ -1023,13 +1023,15 @@
var signature = $(this).closest( '.wpeo-modal' ).find( 'canvas' )[0].toDataURL();
}

let token = $('.modal-signature').find('input[name="token"]').val();

var url = '';
var type = '';
if (elementZone == "private") {
url = document.URL + '&action=addSignature' + signatoryIDPost;
url = document.URL + '&action=addSignature' + signatoryIDPost + '&token=' + token;
type = "POST"
} else {
url = document.URL + '&action=addSignature' + signatoryIDPost;
url = document.URL + '&action=addSignature' + signatoryIDPost + '&token=' + token;
type = "POST";
}

Expand Down Expand Up @@ -1094,7 +1096,8 @@
*/
window.eoxiaJS.signature.autoDownloadSpecimen = function( event ) {
let element = $(this).closest('.file-generation')
let url = document.URL + '&action=builddoc'
let token = $('.digirisk-signature-container').find('input[name="token"]').val();
let url = document.URL + '&action=builddoc&token=' + token
$.ajax({
url: url,
type: "POST",
Expand All @@ -1104,7 +1107,7 @@

window.eoxiaJS.signature.download(path + filename, filename);
$.ajax({
url: document.URL + '&action=remove_file',
url: document.URL + '&action=remove_file&token=' + token,
type: "POST",
success: function ( ) {
},
Expand Down
1 change: 1 addition & 0 deletions public/signature/add_signature.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@
}
?>
<div class="digirisk-signature-container">
<input type="hidden" name="token" value="<?php echo newToken(); ?>">
<div class="wpeo-gridlayout grid-2">
<div class="informations">
<input type="hidden" id="confCAPTCHA" value="<?php echo $conf->global->DIGIRISKDOLIBARR_USE_CAPTCHA ?>"/>
Expand Down

0 comments on commit 3e564e9

Please sign in to comment.