Merge pull request #17453 from nextcloud/fix/axios-csrf-token-update-event-stable17

[stable17] Fix axios csrf token update event
This commit is contained in:
Roeland Jago Douma 2019-10-14 23:16:10 +02:00 committed by GitHub
commit 4e89382532
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 48 additions and 29 deletions

BIN
core/js/dist/login.js vendored

Binary file not shown.

Binary file not shown.

BIN
core/js/dist/main.js vendored

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -19,6 +19,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { subscribe } from '@nextcloud/event-bus'
import {addScript, addStyle} from './legacy-loader'
import {
ajaxConnectionLostHandler,
@ -67,8 +69,7 @@ import {
getProtocol,
} from './host'
import {
getToken as getRequestToken,
subscribe as subscribeToRequestTokenChange,
getToken as getRequestToken
} from './requesttoken'
import {
hideMenus,
@ -257,4 +258,9 @@ export default {
}
// Keep the request token prop in sync
subscribeToRequestTokenChange(token => OC.requestToken = token)
subscribe('csrf-token-update', e => {
OC.requestToken = e.token
// Logging might help debug (Sentry) issues
console.info('OC.requestToken changed', e.token)
})

View file

@ -19,25 +19,22 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
let token = document.getElementsByTagName('head')[0].getAttribute('data-requesttoken');
const observers = []
import { emit } from '@nextcloud/event-bus'
let token = document.getElementsByTagName('head')[0].getAttribute('data-requesttoken')
/**
* @return {string}
*/
export const getToken = () => token
/**
* @param {Function} observer
* @return {number}
*/
export const subscribe = observer => observers.push(observer)
/**
* @param {String} newToken
*/
export const setToken = newToken => {
token = newToken
observers.forEach(o => o(token))
emit('csrf-token-update', {
token
})
}

49
package-lock.json generated
View file

@ -1086,6 +1086,21 @@
"qrcode": "^1.3.3"
}
},
"@nextcloud/event-bus": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/@nextcloud/event-bus/-/event-bus-0.2.1.tgz",
"integrity": "sha512-yerEPTA5lnJ1JV8qYK6sHMWW8m6fxuMEtptVgv7WnGCy2l5rvxDh9vqwk72qX/Z9i2OrC7Jy382TMYbke8b2Qw==",
"requires": {
"core-js": "^3.1.4"
},
"dependencies": {
"core-js": {
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.3.2.tgz",
"integrity": "sha512-S1FfZpeBchkhyoY76YAdFzKS4zz9aOK7EeFaNA2aJlyXyA+sgqz6xdxmLPGXEAf0nF44MVN1kSjrA9Kt3ATDQg=="
}
}
},
"@textlint/ast-node-types": {
"version": "4.2.4",
"resolved": "https://registry.npmjs.org/@textlint/ast-node-types/-/ast-node-types-4.2.4.tgz",
@ -1855,7 +1870,7 @@
},
"bootstrap": {
"version": "4.3.1",
"resolved": "http://registry.npmjs.org/bootstrap/-/bootstrap-4.3.1.tgz",
"resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-4.3.1.tgz",
"integrity": "sha512-rXqOmH1VilAt2DyPzluTi2blhk17bO7ef+zLLPlWvG494pDxcM234pJ8wTc/6R40UWizAIIMgxjvxZg5kmsbag=="
},
"boundary": {
@ -1909,7 +1924,7 @@
},
"browserify-aes": {
"version": "1.2.0",
"resolved": "http://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz",
"resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz",
"integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==",
"dev": true,
"requires": {
@ -1946,7 +1961,7 @@
},
"browserify-rsa": {
"version": "4.0.1",
"resolved": "http://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz",
"resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz",
"integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=",
"dev": true,
"requires": {
@ -1997,7 +2012,7 @@
},
"buffer": {
"version": "4.9.1",
"resolved": "http://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz",
"resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz",
"integrity": "sha1-bRu2AbB6TvztlwlBMgkwJ8lbwpg=",
"dev": true,
"requires": {
@ -2595,7 +2610,7 @@
},
"create-hash": {
"version": "1.2.0",
"resolved": "http://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz",
"resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz",
"integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==",
"dev": true,
"requires": {
@ -2608,7 +2623,7 @@
},
"create-hmac": {
"version": "1.1.7",
"resolved": "http://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz",
"resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz",
"integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==",
"dev": true,
"requires": {
@ -2936,7 +2951,7 @@
},
"diffie-hellman": {
"version": "5.0.3",
"resolved": "http://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz",
"resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz",
"integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==",
"dev": true,
"requires": {
@ -3201,7 +3216,7 @@
},
"events": {
"version": "3.0.0",
"resolved": "http://registry.npmjs.org/events/-/events-3.0.0.tgz",
"resolved": "https://registry.npmjs.org/events/-/events-3.0.0.tgz",
"integrity": "sha512-Dc381HFWJzEOhQ+d8pkNon++bk9h6cdAoAj4iE6Q4y6xgTzySWXlKn05/TVNpjnfRqi/X0EpJEJohPjNI3zpVA==",
"dev": true
},
@ -4248,7 +4263,7 @@
},
"get-stream": {
"version": "4.1.0",
"resolved": "http://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz",
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz",
"integrity": "sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==",
"requires": {
"pump": "^3.0.0"
@ -6344,7 +6359,7 @@
},
"path-browserify": {
"version": "0.0.1",
"resolved": "http://registry.npmjs.org/path-browserify/-/path-browserify-0.0.1.tgz",
"resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.1.tgz",
"integrity": "sha512-BapA40NHICOS+USX9SN4tyhq+A2RrN/Ws5F0Z5aMHDp98Fl86lX8Oti8B7uN93L4Ifv4fHOEA+pQw87gmMO/lQ==",
"dev": true
},
@ -7380,7 +7395,7 @@
},
"safe-regex": {
"version": "1.1.0",
"resolved": "http://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz",
"resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz",
"integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=",
"dev": true,
"requires": {
@ -7516,7 +7531,7 @@
},
"sha.js": {
"version": "2.4.11",
"resolved": "http://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz",
"resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz",
"integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==",
"dev": true,
"requires": {
@ -7853,7 +7868,7 @@
},
"stream-browserify": {
"version": "2.0.2",
"resolved": "http://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.2.tgz",
"resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.2.tgz",
"integrity": "sha512-nX6hmklHs/gr2FuxYDltq8fJA1GDlxKQCz8O/IM4atRqBH8OORmBNgfvW5gG10GT/qQ9u0CzIvr2X5Pkt6ntqg==",
"dev": true,
"requires": {
@ -7972,7 +7987,7 @@
},
"strip-eof": {
"version": "1.0.0",
"resolved": "http://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz",
"resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz",
"integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8="
},
"strip-indent": {
@ -8316,7 +8331,7 @@
},
"tty-browserify": {
"version": "0.0.0",
"resolved": "http://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz",
"resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz",
"integrity": "sha1-oVe6QC2iTpv5V/mqadUk7tQpAaY=",
"dev": true
},
@ -8371,7 +8386,7 @@
},
"underscore": {
"version": "1.9.1",
"resolved": "http://registry.npmjs.org/underscore/-/underscore-1.9.1.tgz",
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.1.tgz",
"integrity": "sha512-5/4etnCkd9c8gwgowi5/om/mYO5ajCaOgdzj/oW+0eQV9WxKBDZw5+ycmKmeaTXjInS/W0BzpGLo2xR2aBwZdg=="
},
"unherit": {
@ -8704,7 +8719,7 @@
},
"vm-browserify": {
"version": "1.1.0",
"resolved": "http://registry.npmjs.org/vm-browserify/-/vm-browserify-1.1.0.tgz",
"resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-1.1.0.tgz",
"integrity": "sha512-iq+S7vZJE60yejDYM0ek6zg308+UZsdtPExWP9VZoCFCz1zkJoXFnAX7aZfd/ZwrkidzdUZL0C/ryW+JwAiIGw==",
"dev": true
},

View file

@ -23,6 +23,7 @@
"dependencies": {
"@babel/polyfill": "^7.4.4",
"@chenfengyuan/vue-qrcode": "^1.0.1",
"@nextcloud/event-bus": "^0.2.1",
"Select2": "git+https://github.com/select2/select2.git#3.4.8",
"autosize": "^4.0.2",
"backbone": "^1.4.0",