Commit 38d9d017 authored by anton's avatar anton
Browse files

Get access_token from $auth plugin instead of localStorage

parent f135168a
Pipeline #50210 passed with stage
in 2 minutes and 48 seconds
......@@ -44,7 +44,7 @@
}
else if (job.finished) {
const headers = {
Authorization: `Bearer ${localStorage.getItem('access_token')}`
Authorization: `Bearer ${this.$auth.token}`
}
this.$store.commit('conversions/removeJobId', jobId)
const detail = this.$store.state.conversions.jobDetails[jobId]
......
......@@ -27,7 +27,7 @@
return {
uploadFields: [],
headers: {
Authorization: `Bearer ${localStorage.getItem('access_token')}`
Authorization: `Bearer ${this.$auth.token}`
}
}
},
......
......@@ -50,7 +50,7 @@
overrideAuthor: false,
skipAcl: false,
headers: {
Authorization: `Bearer ${localStorage.getItem('access_token')}`
Authorization: `Bearer ${_this.$auth.token}`
},
type: constants.mapClasses.MAP_CLASS_GRID,
payload: {},
......
......@@ -71,6 +71,7 @@
},
duration () {
if (this.annotation && this.annotation.target.selector) {
console.log(this.annotation.target.selector)
return this.annotation.target.selector.getDuration().toFormat(constants.config.TIMECODE_FORMAT_DURATION)
}
}
......
......@@ -57,7 +57,7 @@
overrideAuthor: false,
skipAcl: false,
headers: {
Authorization: `Bearer ${localStorage.getItem('access_token')}`
Authorization: `${this.$auth.tokenType} ${this.$auth.token}`
},
type: constants.mapClasses.MAP_CLASS_TIMELINE,
payload: undefined,
......
......@@ -63,7 +63,7 @@
// const fetchMetaData = async (media) => {
// let mediaMeta = []
// const headers = {
// Authorization: `Bearer ${localStorage.getItem('access_token')}`
// Authorization: `Bearer ${this.$auth.token}`
// }
// for (let v of media) {
// try {
......
......@@ -7,6 +7,7 @@ export default ({ Vue }) => {
debug: true,
connection: `${process.env.SOCKETS_HOST || window.SOCKETS_HOST}`,
query: {
// FIXME: token key is dynamic
token: localStorage.getItem('access_token')
}
}))
......
......@@ -8,14 +8,14 @@ const acl = {
actions: {
async set (context, { role, id, permissions }) {
const headers = {
Authorization: `Bearer ${localStorage.getItem('access_token')}`
Authorization: `${this.$router.app.$auth.tokenType} ${this.$router.app.$auth.token}`
}
const query = `?role=${encodeURIComponent(role)}&resource=${encodeURIComponent(id)}`
await axios.put(`${process.env.API_HOST}/acl${query}`, permissions, { headers })
},
async remove (context, { role, id, permission }) {
const headers = {
Authorization: `Bearer ${localStorage.getItem('access_token')}`
Authorization: `${this.$router.app.$auth.tokenType} ${this.$router.app.$auth.token}`
}
const query = `?role=${encodeURIComponent(role)}&resource=${encodeURIComponent(id)}` +
`&permission=${encodeURIComponent(permission)}`
......@@ -23,7 +23,7 @@ const acl = {
},
async isRoleAllowed (context, { role, id, permission }) {
const headers = {
Authorization: `Bearer ${localStorage.getItem('access_token')}`
Authorization: `${this.$router.app.$auth.tokenType} ${this.$router.app.$auth.token}`
}
let permissions
const query = `?role=${encodeURIComponent(role)}&resource=${encodeURIComponent(id)}` +
......
......@@ -9,7 +9,7 @@ const files = {
async list (context, bucketName) {
const config = {
headers: {
Authorization: `Bearer ${localStorage.getItem('access_token')}`
Authorization: `${this.$router.app.$auth.tokenType} ${this.$router.app.$auth.token}`
}
}
let result
......@@ -24,7 +24,7 @@ const files = {
async delete (context, [bucketName, assetName]) {
const config = {
headers: {
Authorization: `Bearer ${localStorage.getItem('access_token')}`
Authorization: `${this.$router.app.$auth.tokenType} ${this.$router.app.$auth.token}`
}
}
await axios.delete(`${process.env.STORAGE_HOST}/files/${bucketName}/${assetName}`, config)
......
......@@ -28,7 +28,7 @@ const metadata = {
if (!this.$router.app.$socket) throw new Error('Metadata: Socket is not available')
this.$router.app.$socket.emit(
'metadata:get',
{ url: payload.body.source.id, token: localStorage.getItem('access_token') },
{ url: payload.body.source.id, token: this.$router.app.$auth.token },
(err, data) => {
if (err) reject(err)
else resolve(data)
......@@ -41,6 +41,7 @@ const metadata = {
}
}
catch (err) {
console.error('metadta', err)
if (!err.response || err.response.status > 404) console.error(err.message)
}
}
......
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