From 8002694c96bc0862c39f741b17941ffc0f799d87 Mon Sep 17 00:00:00 2001 From: jekkos Date: Tue, 5 Jul 2016 17:53:11 +0200 Subject: [PATCH] Make csrf token generation more generic using dataFilter in ajaxSetup (#597, #599) --- application/views/customers/form.php | 3 +-- application/views/items/form.php | 1 - application/views/partial/header_js.php | 8 +++++++- application/views/receivings/receiving.php | 6 ++++-- application/views/sales/form.php | 1 - application/views/sales/register.php | 1 - 6 files changed, 12 insertions(+), 8 deletions(-) diff --git a/application/views/customers/form.php b/application/views/customers/form.php index 47d14dc5f..95175f1e7 100644 --- a/application/views/customers/form.php +++ b/application/views/customers/form.php @@ -83,11 +83,10 @@ $(document).ready(function() submitHandler:function(form) { $(form).ajaxSubmit({ - beforeSerialize: setup_csrf_token(), success:function(response) { dialog_support.hide(); - table_support.handle_submit('', response); + table_support.handle_submit('', response); }, dataType:'json' }); diff --git a/application/views/items/form.php b/application/views/items/form.php index a114ef328..b0621ce2d 100644 --- a/application/views/items/form.php +++ b/application/views/items/form.php @@ -331,7 +331,6 @@ $('#item_form').validate($.extend({ submitHandler: function(form, event) { $(form).ajaxSubmit({ - beforeSerialize: setup_csrf_token, success: function(response) { var stay_open = dialog_support.clicked_id() != 'submit'; if (stay_open) diff --git a/application/views/partial/header_js.php b/application/views/partial/header_js.php index 647112d94..b7074213f 100644 --- a/application/views/partial/header_js.php +++ b/application/views/partial/header_js.php @@ -36,5 +36,11 @@ setup_csrf_token(); - $(document).ajaxComplete(setup_csrf_token); + $.ajaxSetup({ + dataFilter: function(data) { + setup_csrf_token(); + return data; + } + }); + \ No newline at end of file diff --git a/application/views/receivings/receiving.php b/application/views/receivings/receiving.php index 47416444d..01f95e962 100644 --- a/application/views/receivings/receiving.php +++ b/application/views/receivings/receiving.php @@ -85,7 +85,10 @@ if (isset($success)) 'item', 'id'=>'item', 'class'=>'form-control input-sm', 'size'=>'50', 'tabindex'=>'1')); ?>
  • - @@ -493,7 +496,6 @@ $(document).ready(function() { if(response.success) { - setup_csrf_token(); if (resource.match(/suppliers$/)) { $("#supplier").attr("value",response.id); diff --git a/application/views/sales/form.php b/application/views/sales/form.php index 650608f88..c5aa854de 100755 --- a/application/views/sales/form.php +++ b/application/views/sales/form.php @@ -164,7 +164,6 @@ $(document).ready(function() { $(this).ajaxSubmit( { - beforeSerialize: setup_csrf_token(), success: function(response) { dialog_support.hide(); diff --git a/application/views/sales/register.php b/application/views/sales/register.php index b1a44662f..991059f61 100644 --- a/application/views/sales/register.php +++ b/application/views/sales/register.php @@ -672,7 +672,6 @@ $(document).ready(function() table_support.handle_submit = function(resource, response, stay_open) { if(response.success) { - setup_csrf_token(); if (resource.match(/customers$/)) { $("#customer").val(response.id);