2019-09-25 19:19:42 +03:00
|
|
|
/**
|
2019-05-10 15:18:08 +03:00
|
|
|
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
|
|
|
|
*
|
|
|
|
* @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
|
|
|
|
*
|
|
|
|
* @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 <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2019-10-04 13:10:43 +03:00
|
|
|
import { emit } from '@nextcloud/event-bus'
|
|
|
|
|
2019-09-25 19:19:42 +03:00
|
|
|
let token = document.getElementsByTagName('head')[0].getAttribute('data-requesttoken')
|
2019-05-10 15:18:08 +03:00
|
|
|
|
|
|
|
/**
|
2019-09-25 19:19:42 +03:00
|
|
|
* @returns {string}
|
2019-05-10 15:18:08 +03:00
|
|
|
*/
|
|
|
|
export const getToken = () => token
|
|
|
|
|
|
|
|
/**
|
2019-09-25 19:19:42 +03:00
|
|
|
* @param {String} newToken new token
|
2019-05-10 15:18:08 +03:00
|
|
|
*/
|
|
|
|
export const setToken = newToken => {
|
|
|
|
token = newToken
|
2019-10-04 13:10:43 +03:00
|
|
|
|
|
|
|
emit('csrf-token-update', {
|
2019-11-13 15:05:10 +03:00
|
|
|
token,
|
2019-10-04 13:10:43 +03:00
|
|
|
})
|
2019-05-10 15:18:08 +03:00
|
|
|
}
|