Fix token injection if unlogged user

pull/5386/head
Chocobozzz 2022-10-26 14:28:38 +02:00
parent b67580aa65
commit 49e7e4d9ff
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
2 changed files with 4 additions and 2 deletions

View File

@ -210,7 +210,7 @@ class PeerTubePlugin extends Plugin {
lastViewEvent = undefined lastViewEvent = undefined
// Server won't save history, so save the video position in local storage // Server won't save history, so save the video position in local storage
if (!this.authorizationHeader) { if (!this.authorizationHeader()) {
saveVideoWatchHistory(this.videoUUID, currentTime) saveVideoWatchHistory(this.videoUUID, currentTime)
} }
}, this.CONSTANTS.USER_VIEW_VIDEO_INTERVAL) }, this.CONSTANTS.USER_VIEW_VIDEO_INTERVAL)
@ -228,7 +228,7 @@ class PeerTubePlugin extends Plugin {
'Content-type': 'application/json; charset=UTF-8' 'Content-type': 'application/json; charset=UTF-8'
}) })
if (this.authorizationHeader) headers.set('Authorization', this.authorizationHeader()) if (this.authorizationHeader()) headers.set('Authorization', this.authorizationHeader())
return fetch(this.videoViewUrl, { method: 'POST', body: JSON.stringify(body), headers }) return fetch(this.videoViewUrl, { method: 'POST', body: JSON.stringify(body), headers })
} }

View File

@ -27,6 +27,8 @@ export class AuthHTTP {
} }
getHeaderTokenValue () { getHeaderTokenValue () {
if (!this.userOAuthTokens) return null
return `${this.userOAuthTokens.tokenType} ${this.userOAuthTokens.accessToken}` return `${this.userOAuthTokens.tokenType} ${this.userOAuthTokens.accessToken}`
} }