From 19af86728865987053fe27f5f5b840fbcf8962b3 Mon Sep 17 00:00:00 2001 From: Julian Herrero Date: Thu, 29 Jun 2023 16:24:19 +0200 Subject: [PATCH] Refresh CSRF Token when using Turbolinks --- app/assets/javascripts/application.js | 2 ++ app/assets/javascripts/authenticity_token_refresh.js | 8 ++++++++ 2 files changed, 10 insertions(+) create mode 100644 app/assets/javascripts/authenticity_token_refresh.js diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index d37f221a7d2..4dcf9d86586 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -111,6 +111,7 @@ //= require budget_hide_money //= require datepicker //= require link_to_top +//= require authenticity_token_refresh //= require_tree ./admin //= require_tree ./sdg //= require_tree ./sdg_management @@ -172,6 +173,7 @@ var initialize_modules = function() { App.LinkToTop.initialize(); App.SDGRelatedListSelector.initialize(); App.SDGManagementRelationSearch.initialize(); + App.AuthenticityTokenRefresh.initialize(); }; var destroy_non_idempotent_modules = function() { diff --git a/app/assets/javascripts/authenticity_token_refresh.js b/app/assets/javascripts/authenticity_token_refresh.js new file mode 100644 index 00000000000..df554f7ce3c --- /dev/null +++ b/app/assets/javascripts/authenticity_token_refresh.js @@ -0,0 +1,8 @@ +(function() { + "use strict"; + App.AuthenticityTokenRefresh = { + initialize: function() { + $.rails.refreshCSRFTokens(); + } + }; +}).call(this);