Skip to content

Commit c8f422a

Browse files
authored
Merge pull request #2339 from nextcloud/fix/noid/requesttoken-refresh
2 parents affb7c0 + e870f7e commit c8f422a

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

js/viewer-main.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ var b4=Object.defineProperty;var y4=(e,r,a)=>r in e?b4(e,r,{enumerable:!0,config
465465
* You should have received a copy of the GNU Affero General Public License
466466
* along with this program. If not, see <http://www.gnu.org/licenses/>.
467467
*
468-
*/const dT={"X-Requested-With":"XMLHttpRequest",requesttoken:x0()||""},XD=()=>HD(k1(),Hs()?{username:R1(),password:"",headers:dT}:{headers:dT});/*! third party licenses: js/vendor.LICENSE.txt *//**
468+
*/const dT=()=>({"X-Requested-With":"XMLHttpRequest",requesttoken:x0()||""}),XD=()=>HD(k1(),Hs()?{username:R1(),password:"",headers:dT()}:{headers:dT()});/*! third party licenses: js/vendor.LICENSE.txt *//**
469469
* @copyright Copyright (c) 2019 John Molakvoæ <[email protected]>
470470
*
471471
* @author John Molakvoæ <[email protected]>

js/viewer-main.mjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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)