Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable29] fix(requesttoken): Make sure to use the correct requesttoken in WebdavClient #2342

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading