kopia lustrzana https://dev.funkwhale.audio/funkwhale/funkwhale
Merge branch '1153-jwt' into 'develop'
Resolve "403 on POST requests" Closes #1153 See merge request funkwhale/funkwhale!1138plugins-v3
commit
a82ff6f61b
|
@ -436,7 +436,6 @@ export default {
|
||||||
param = "token"
|
param = "token"
|
||||||
value = this.$store.state.auth.scopedTokens.listen
|
value = this.$store.state.auth.scopedTokens.listen
|
||||||
}
|
}
|
||||||
console.log('HELLO', param, value, this.$store.state.auth.scopedTokens)
|
|
||||||
sources.forEach(e => {
|
sources.forEach(e => {
|
||||||
e.url = url.updateQueryString(e.url, param, value)
|
e.url = url.updateQueryString(e.url, param, value)
|
||||||
})
|
})
|
||||||
|
|
|
@ -70,7 +70,10 @@ export default {
|
||||||
if (!self.$store.state.auth.authenticated) {
|
if (!self.$store.state.auth.authenticated) {
|
||||||
return xhrObject
|
return xhrObject
|
||||||
}
|
}
|
||||||
xhrObject.setRequestHeader('Authorization', self.$store.getters['auth/header'])
|
|
||||||
|
if (self.$store.state.auth.oauth.accessToken) {
|
||||||
|
xhrObject.setRequestHeader('Authorization', self.$store.getters['auth/header'])
|
||||||
|
}
|
||||||
return xhrObject
|
return xhrObject
|
||||||
},
|
},
|
||||||
onResponse: function (initialResponse) {
|
onResponse: function (initialResponse) {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<script>
|
<script>
|
||||||
import FileUpload from 'vue-upload-component'
|
import FileUpload from 'vue-upload-component'
|
||||||
|
import {setCsrf} from '@/utils'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
extends: FileUpload,
|
extends: FileUpload,
|
||||||
|
@ -32,7 +33,10 @@ export default {
|
||||||
form.append(this.name, file.file, filename)
|
form.append(this.name, file.file, filename)
|
||||||
let xhr = new XMLHttpRequest()
|
let xhr = new XMLHttpRequest()
|
||||||
xhr.open('POST', file.postAction)
|
xhr.open('POST', file.postAction)
|
||||||
xhr.setRequestHeader('Authorization', this.$store.getters['auth/header'])
|
setCsrf(xhr)
|
||||||
|
if (this.$store.state.auth.oauth.accessToken) {
|
||||||
|
xhr.setRequestHeader('Authorization', this.$store.getters['auth/header'])
|
||||||
|
}
|
||||||
return this.uploadXhr(xhr, file, form)
|
return this.uploadXhr(xhr, file, form)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,10 @@ export default {
|
||||||
apiSettings: {
|
apiSettings: {
|
||||||
url: this.$store.getters['instance/absoluteUrl']('/api/v1/tags/?name__startswith={query}&ordering=length&page_size=5'),
|
url: this.$store.getters['instance/absoluteUrl']('/api/v1/tags/?name__startswith={query}&ordering=length&page_size=5'),
|
||||||
beforeXHR: function (xhrObject) {
|
beforeXHR: function (xhrObject) {
|
||||||
xhrObject.setRequestHeader('Authorization', self.$store.getters['auth/header'])
|
|
||||||
|
if (self.$store.state.auth.oauth.accessToken) {
|
||||||
|
xhrObject.setRequestHeader('Authorization', self.$store.getters['auth/header'])
|
||||||
|
}
|
||||||
return xhrObject
|
return xhrObject
|
||||||
},
|
},
|
||||||
onResponse(response) {
|
onResponse(response) {
|
||||||
|
|
|
@ -114,7 +114,9 @@ export default {
|
||||||
settings.apiSettings = {
|
settings.apiSettings = {
|
||||||
url: self.$store.getters['instance/absoluteUrl'](f.autocomplete + '?' + f.autocomplete_qs),
|
url: self.$store.getters['instance/absoluteUrl'](f.autocomplete + '?' + f.autocomplete_qs),
|
||||||
beforeXHR: function (xhrObject) {
|
beforeXHR: function (xhrObject) {
|
||||||
xhrObject.setRequestHeader('Authorization', self.$store.getters['auth/header'])
|
if (self.$store.state.auth.oauth.accessToken) {
|
||||||
|
xhrObject.setRequestHeader('Authorization', self.$store.getters['auth/header'])
|
||||||
|
}
|
||||||
return xhrObject
|
return xhrObject
|
||||||
},
|
},
|
||||||
onResponse: function (initialResponse) {
|
onResponse: function (initialResponse) {
|
||||||
|
|
|
@ -33,3 +33,15 @@ export function parseAPIErrors(responseData, parentField) {
|
||||||
}
|
}
|
||||||
return errors
|
return errors
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getCookie(name) {
|
||||||
|
return document.cookie
|
||||||
|
.split('; ')
|
||||||
|
.find(row => row.startsWith(name))
|
||||||
|
.split('=')[1];
|
||||||
|
}
|
||||||
|
export function setCsrf(xhr) {
|
||||||
|
if (getCookie('csrftoken')) {
|
||||||
|
xhr.setRequestHeader('X-CSRFToken', getCookie('csrftoken'))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue