Commit 977140b2 authored by anton's avatar anton
Browse files

Authenticate local assets in CellImage.vue and CellMedia.vue

parent e8df6d64
Pipeline #153098 passed with stage
in 1 minute and 13 seconds
......@@ -40,14 +40,17 @@
}),
imgSrc () {
let src = this.cell.source._value.content
if (process.env.STORAGE_HOST && src.indexOf(process.env.STORAGE_HOST) === 0) {
if (this.user && this.$auth.token) {
if (this.isApiSource) {
if (this.$auth.token) {
src += src.indexOf('?') === -1 ? '?' : '&'
src += `token=${encodeURIComponent(this.$auth.token)}`
src += `${encodeURIComponent(this.$auth.tokenType.toLowerCase())}=${encodeURIComponent(this.$auth.token)}`
}
}
return src
},
isApiSource () {
return this.cell.source._value.content.indexOf(process.env.API_HOST) === 0
},
link () {
if (!this.cell) return
return this.cell.source._value.link
......
......@@ -5,6 +5,7 @@
template(v-if="display")
media-player(
v-if="video",
:auth="playerAuth",
:class="{ hidePlayer: !showPlayer }",
ref='videoPlayer',
:annotation="video",
......@@ -47,6 +48,19 @@
}
}
},
computed: {
playerAuth () {
const auth = { query: {} }
if (this.isApiSource && this.$auth.token) {
auth.query[this.$auth.tokenType.toLowerCase()] = this.$auth.token
}
return auth
},
isApiSource () {
if (!this.video) return
return this.video.body.source.id.indexOf(process.env.API_HOST) === 0
}
},
async mounted () {
if (this.cell && this.cell.id && this.cell.source._value.id) {
this.video = await this.$store.dispatch('annotations/get', this.cell.source._value.id)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment