From 8cda11379780908ff1371ac1f3e1fdd9c06782d1 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 1 Aug 2023 09:12:10 +0200 Subject: [PATCH] Bug 34369: Pass csrf token from syspref API client (for Vue app) --- .../intranet-tmpl/prog/en/modules/preservation/home.tt | 1 + .../prog/js/vue/fetch/system-preferences-api-client.js | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/preservation/home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/preservation/home.tt index 0c3d01ebc6c..45c1c240185 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/preservation/home.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/preservation/home.tt @@ -34,6 +34,7 @@ const db_columns = [% To.json(db_columns) | $raw %]; const api_mappings = [% To.json(api_mappings) | $raw %]; const notice_templates = [% To.json(notice_templates || []) | $raw %]; + const csrf_token = "[% Koha.GenerateCSRF | $raw %]"; diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/system-preferences-api-client.js b/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/system-preferences-api-client.js index 9cfcabf08f4..16a75a2caed 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/system-preferences-api-client.js +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/system-preferences-api-client.js @@ -6,7 +6,6 @@ export class SysprefAPIClient extends HttpClient { baseURL: "/cgi-bin/koha/svc/config/systempreferences", }); } - get sysprefs() { return { get: variable => @@ -16,7 +15,11 @@ export class SysprefAPIClient extends HttpClient { update: (variable, value) => this.post({ endpoint: "", - body: "pref_%s=%s".format(variable, value), + body: "pref_%s=%s&csrf_token=%s".format( + variable, + value, + csrf_token + ), headers: { "Content-Type": "application/x-www-form-urlencoded;charset=utf-8", -- 2.25.1