Skip to content

Commit 2249d46

Browse files
SystemKeeperbackportbot[bot]
authored andcommitted
fix(requesttoken): Make sure to use the correct requesttoken in WebdavClient
Signed-off-by: Marcel Müller <marcel-mueller@gmx.de> [skip ci]
1 parent ff6666a commit 2249d46

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/services/WebdavClient.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,20 @@ import { createClient } from 'webdav'
2424
import { getRootPath, getToken, isPublic } from '../utils/davUtils'
2525
import { getRequestToken } from '@nextcloud/auth'
2626

27-
const headers = {
28-
// Add this so the server knows it is an request from the browser
29-
'X-Requested-With': 'XMLHttpRequest',
30-
// Add the request token to the request
31-
requesttoken: getRequestToken() || '',
27+
// Use a method for the headers, to always get the current request token
28+
const getHeaders = () => {
29+
return {
30+
// Add this so the server knows it is an request from the browser
31+
'X-Requested-With': 'XMLHttpRequest',
32+
// Add the request token to the request
33+
requesttoken: getRequestToken() || '',
34+
}
3235
}
3336

3437
export const getClient = () => {
3538
const client = createClient(getRootPath(), isPublic()
36-
? { username: getToken(), password: '', headers }
37-
: { headers },
39+
? { username: getToken(), password: '', headers: getHeaders() }
40+
: { headers: getHeaders() },
3841
)
3942

4043
return client

0 commit comments

Comments
 (0)