diff --git a/apps/files_sharing/js/dist/personal-settings.js.map b/apps/files_sharing/js/dist/personal-settings.js.map index db112e1c25ae99714a32ba2c2f5192e4dbcf664f..4fae4453a38d595662cbc4c732a4c0f9b3fb51f9 100644 Binary files a/apps/files_sharing/js/dist/personal-settings.js.map and b/apps/files_sharing/js/dist/personal-settings.js.map differ diff --git a/apps/files_sharing/src/components/PersonalSettings.vue b/apps/files_sharing/src/components/PersonalSettings.vue index ec7255480eb4251bb246076cf3e221043a97ce93..dd10dec10d2a19d9b2da136e2bde647994206884 100644 --- a/apps/files_sharing/src/components/PersonalSettings.vue +++ b/apps/files_sharing/src/components/PersonalSettings.vue @@ -20,7 +20,7 @@ --> <template> - <div id="files-sharing-personal-settings" class="section" v-if="!enforceAcceptShares"> + <div v-if="!enforceAcceptShares" id="files-sharing-personal-settings" class="section"> <h2>{{ t('files', 'Sharing') }}</h2> <p> <input id="files-sharing-personal-settings-accept" diff --git a/apps/settings/js/vue-1.js b/apps/settings/js/vue-1.js index bed3ebc1995bb9b2d93c75d5c64175a966771262..7381f33fd95975d115f26fffc494b3660645e4d8 100644 Binary files a/apps/settings/js/vue-1.js and b/apps/settings/js/vue-1.js differ diff --git a/apps/settings/js/vue-1.js.map b/apps/settings/js/vue-1.js.map index 7ece82bca71ea920bfa259b59863d09164073582..7ff54299b074e69abb94ca0441b6e40adde0de90 100644 Binary files a/apps/settings/js/vue-1.js.map and b/apps/settings/js/vue-1.js.map differ diff --git a/apps/settings/js/vue-2.js b/apps/settings/js/vue-2.js index df74391031264f15b8868c935785776acec89b5c..9d817ac604bf7f50fa7fc8be8339d32386287cba 100644 Binary files a/apps/settings/js/vue-2.js and b/apps/settings/js/vue-2.js differ diff --git a/apps/settings/js/vue-2.js.map b/apps/settings/js/vue-2.js.map index 363e213f86b8f026f8e711003473b738b0d94b53..1bb4286ce6c9a1a11abc642778963f465aeb1a99 100644 Binary files a/apps/settings/js/vue-2.js.map and b/apps/settings/js/vue-2.js.map differ diff --git a/core/js/dist/login.js b/core/js/dist/login.js index 2552fe2657f38340295072c3ef1251133bdeb70b..1de2367e4e2d509089c931556d0f4608928089f6 100644 Binary files a/core/js/dist/login.js and b/core/js/dist/login.js differ diff --git a/core/js/dist/login.js.map b/core/js/dist/login.js.map index 21ded5640cd2ceaf761de2ea8ddc545c6b172cbc..227036c593183900bf32e71b1bba93568f3a8630 100644 Binary files a/core/js/dist/login.js.map and b/core/js/dist/login.js.map differ diff --git a/core/js/dist/main.js b/core/js/dist/main.js index bcadeecd2422c4390a7be710c946dda8ada05571..59d7f90fd3f543103985d69f53d4203ddd409ba0 100644 Binary files a/core/js/dist/main.js and b/core/js/dist/main.js differ diff --git a/core/js/dist/main.js.map b/core/js/dist/main.js.map index 0f5cd1ca52ea5646553f9b7f6a00b7b749cbcc8e..74f855601278fda520d61527aacf6d206aa35179 100644 Binary files a/core/js/dist/main.js.map and b/core/js/dist/main.js.map differ diff --git a/core/js/dist/maintenance.js b/core/js/dist/maintenance.js index 5168b15c696cd300acfdf90add30835d09201e18..33dac564ca4fc01f244ad0607cbb542461d48e7c 100644 Binary files a/core/js/dist/maintenance.js and b/core/js/dist/maintenance.js differ diff --git a/core/js/dist/maintenance.js.map b/core/js/dist/maintenance.js.map index 6bebb5f5617783362d35f255cad176bdc1bc1d02..b146ab4b94199d755b1e535b323986bbc1b733ac 100644 Binary files a/core/js/dist/maintenance.js.map and b/core/js/dist/maintenance.js.map differ diff --git a/core/src/OC/requesttoken.js b/core/src/OC/requesttoken.js index b25fdafd5b4a466ce784d186212d0486a003ab5b..6c011879b8bfca73181dfcf4f8a89781dc4169a8 100644 --- a/core/src/OC/requesttoken.js +++ b/core/src/OC/requesttoken.js @@ -21,20 +21,35 @@ import { emit } from '@nextcloud/event-bus' -let token = document.getElementsByTagName('head')[0].getAttribute('data-requesttoken') +/** + * @private + * @param {Document} global the document to read the initial value from + * @param {Function} emit the function to invoke for every new token + * @returns {Object} + */ +export const manageToken = (global, emit) => { + let token = global.getElementsByTagName('head')[0].getAttribute('data-requesttoken') + + return { + getToken: () => token, + setToken: newToken => { + token = newToken + + emit('csrf-token-update', { + token, + }) + }, + } +} + +const manageFromDocument = manageToken(document, emit) /** * @returns {string} */ -export const getToken = () => token +export const getToken = manageFromDocument.getToken /** * @param {String} newToken new token */ -export const setToken = newToken => { - token = newToken - - emit('csrf-token-update', { - token, - }) -} +export const setToken = manageFromDocument.setToken diff --git a/core/src/OCP/initialstate.js b/core/src/OCP/initialstate.js deleted file mode 100644 index 57a1162bedbe7743954d48ac0b6db6d8fe407de3..0000000000000000000000000000000000000000 --- a/core/src/OCP/initialstate.js +++ /dev/null @@ -1,29 +0,0 @@ -/* - * @copyright Copyright (c) 2019 Roeland Jago Douma <roeland@famdouma.nl> - * - * @author Roeland Jago Douma <roeland@famdouma.nl> - * - * @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/>. - * - */ - -/** - * @namespace OCP.InitialState - */ - -import { loadState as load } from '@nextcloud/initial-state' - -export const loadState = load diff --git a/core/src/session-heartbeat.js b/core/src/session-heartbeat.js index 88c519e1dde0cf67963a4d1ae9341e27f983e878..a941720d853b417cd0ecf5234c73ef485cc81d82 100644 --- a/core/src/session-heartbeat.js +++ b/core/src/session-heartbeat.js @@ -103,14 +103,14 @@ export const initSessionHeartBeat = () => { // Let apps know we're online and requests will have the new token emit('networkOnline', { - success: true + success: true, }) } catch (e) { console.error('could not update session token after resuming network', e) // Let apps know we're online but requests might have an outdated token emit('networkOnline', { - success: false + success: false, }) } }) diff --git a/core/src/tests/OC/requesttoken.spec.js b/core/src/tests/OC/requesttoken.spec.js index 401d3766af4ff6cfa85260be8d0972539108a6f2..d19a4b8e9c8d6a805b25c93b2ec28dcd898dcbbf 100644 --- a/core/src/tests/OC/requesttoken.spec.js +++ b/core/src/tests/OC/requesttoken.spec.js @@ -19,12 +19,37 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +import {JSDOM} from 'jsdom' import {subscribe, unsubscribe} from '@nextcloud/event-bus' -import {setToken} from '../../OC/requesttoken' +import {manageToken, setToken} from '../../OC/requesttoken' describe('request token', () => { + let dom + let emit + let manager + const token = 'abc123' + + beforeEach(() => { + dom = new JSDOM() + emit = sinon.spy() + const head = dom.window.document.getElementsByTagName('head')[0] + head.setAttribute('data-requesttoken', token) + + manager = manageToken(dom.window.document, emit) + }) + + it('reads the token from the document', () => { + expect(manager.getToken()).to.equal('abc123') + }) + + it('remembers the updated token', () => { + manager.setToken('bca321') + + expect(manager.getToken()).to.equal('bca321') + }) + describe('@nextcloud/auth integration', () => { let listener