From c624c102a6edbe51256aaf5c0025ff6331018f32 Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Fri, 10 May 2019 14:18:08 +0200 Subject: Move OC.requestToken to the bundle, deprecate oc_requesttoken Signed-off-by: Christoph Wurst --- core/src/jquery/index.js | 1 + core/src/jquery/requesttoken.js | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 core/src/jquery/requesttoken.js (limited to 'core/src/jquery') diff --git a/core/src/jquery/index.js b/core/src/jquery/index.js index 43b379fd2e5..e2efc76bdf1 100644 --- a/core/src/jquery/index.js +++ b/core/src/jquery/index.js @@ -28,6 +28,7 @@ import './filterattr' import './ocdialog' import './octemplate' import './placeholder' +import './requesttoken' import './selectrange' import './showpassword' import './tipsy' diff --git a/core/src/jquery/requesttoken.js b/core/src/jquery/requesttoken.js new file mode 100644 index 00000000000..a8fb024d04a --- /dev/null +++ b/core/src/jquery/requesttoken.js @@ -0,0 +1,31 @@ +/* + * @copyright 2019 Christoph Wurst + * + * @author 2019 Christoph Wurst + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +import $ from 'jquery' + +import {getToken} from '../OC/requesttoken' + +$(document).on('ajaxSend',function(elm, xhr, settings) { + if(settings.crossDomain === false) { + xhr.setRequestHeader('requesttoken', getToken()); + xhr.setRequestHeader('OCS-APIREQUEST', 'true'); + } +}); -- cgit v1.2.3