Skip to content

Commit

Permalink
fix(requesttoken): Make sure to use the correct requesttoken in Webda…
Browse files Browse the repository at this point in the history
…vClient

Signed-off-by: Marcel Müller <marcel-mueller@gmx.de>
  • Loading branch information
SystemKeeper committed Jun 19, 2024
1 parent ff6666a commit 3eca354
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion js/viewer-main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ var b4=Object.defineProperty;var y4=(e,r,a)=>r in e?b4(e,r,{enumerable:!0,config
* 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/>.
*
*/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 *//**
*/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 *//**
* @copyright Copyright (c) 2019 John Molakvoæ <skjnldsv@protonmail.com>
*
* @author John Molakvoæ <skjnldsv@protonmail.com>
Expand Down
2 changes: 1 addition & 1 deletion js/viewer-main.mjs.map

Large diffs are not rendered by default.

17 changes: 10 additions & 7 deletions src/services/WebdavClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,20 @@ import { createClient } from 'webdav'
import { getRootPath, getToken, isPublic } from '../utils/davUtils'
import { getRequestToken } from '@nextcloud/auth'

const headers = {
// Add this so the server knows it is an request from the browser
'X-Requested-With': 'XMLHttpRequest',
// Add the request token to the request
requesttoken: getRequestToken() || '',
// Use a method for the headers, to always get the current request token
const getHeaders = () => {
return {
// Add this so the server knows it is an request from the browser
'X-Requested-With': 'XMLHttpRequest',
// Add the request token to the request
requesttoken: getRequestToken() || '',
}
}

export const getClient = () => {
const client = createClient(getRootPath(), isPublic()
? { username: getToken(), password: '', headers }
: { headers },
? { username: getToken(), password: '', headers: getHeaders() }
: { headers: getHeaders() },
)

return client
Expand Down

0 comments on commit 3eca354

Please sign in to comment.