Fixed #15 again, now check authorization also using query param

This commit is contained in:
Eliot Berriot 2017-06-29 02:27:35 +02:00
parent 795cd7beb9
commit 3ccb70d0a8
9 changed files with 98 additions and 8 deletions

View file

@ -5,6 +5,8 @@ import Audio from '@/audio'
import backend from '@/audio/backend'
import radios from '@/radios'
import Vue from 'vue'
import url from '@/utils/url'
import auth from '@/auth'
class Queue {
constructor (options = {}) {
@ -181,7 +183,17 @@ class Queue {
if (!file) {
return this.next()
}
this.audio = new Audio(backend.absoluteUrl(file.path), {
let path = backend.absoluteUrl(file.path)
if (auth.user.authenticated) {
// we need to send the token directly in url
// so authentication can be checked by the backend
// because for audio files we cannot use the regular Authentication
// header
path = url.updateQueryString(path, 'jwt', auth.getAuthToken())
}
this.audio = new Audio(path, {
preload: true,
autoplay: true,
rate: 1,