global auth check, fix #11
This commit is contained in:
parent
efda8d4cdf
commit
643d9d09e9
@ -231,7 +231,6 @@ export default {
|
||||
|
||||
if (process.browser) {
|
||||
this.interval = setInterval(async () => {
|
||||
await this.$store.dispatch('auth/inspectToken')
|
||||
const response = await this.$axios.get('api/player/stats/?stats=all')
|
||||
this.stat = response.data
|
||||
}, 2000)
|
||||
|
@ -87,7 +87,6 @@ export default {
|
||||
|
||||
methods: {
|
||||
async getLog (type) {
|
||||
await this.$store.dispatch('auth/inspectToken')
|
||||
this.logName = type
|
||||
const response = await this.$axios.get(`api/player/log/?type=${type}&date=${this.listDate}`)
|
||||
|
||||
@ -98,7 +97,6 @@ export default {
|
||||
}
|
||||
},
|
||||
async getSystemLog () {
|
||||
await this.$store.dispatch('auth/inspectToken')
|
||||
const response = await this.$axios.post('api/player/system/', { run: 'log' })
|
||||
|
||||
if (response.data.data) {
|
||||
|
@ -294,11 +294,7 @@ export default {
|
||||
...mapState('media', ['crumbs', 'folderTree'])
|
||||
},
|
||||
|
||||
async created () {
|
||||
await this.$store.dispatch('auth/inspectToken')
|
||||
await this.$store.dispatch('config/getGuiConfig')
|
||||
await this.$store.dispatch('config/getPlayoutConfig')
|
||||
|
||||
created () {
|
||||
this.extensions = [...this.configPlayout.storage.extensions, ...this.configGui.extra_extensions].join(' ')
|
||||
this.getPath(this.extensions, '')
|
||||
},
|
||||
@ -307,7 +303,6 @@ export default {
|
||||
async getPath (extensions, path) {
|
||||
this.lastPath = path
|
||||
this.isLoading = true
|
||||
await this.$store.dispatch('auth/inspectToken')
|
||||
await this.$store.dispatch('media/getTree', { extensions, path })
|
||||
this.isLoading = false
|
||||
},
|
||||
@ -349,7 +344,6 @@ export default {
|
||||
|
||||
async onSubmitCreateFolder (evt) {
|
||||
evt.preventDefault()
|
||||
await this.$store.dispatch('auth/inspectToken')
|
||||
|
||||
await this.$axios.post(
|
||||
'api/player/media/op/',
|
||||
@ -389,7 +383,6 @@ export default {
|
||||
}
|
||||
|
||||
for (const [i, file] of this.inputFiles.entries()) {
|
||||
await this.$store.dispatch('auth/inspectToken')
|
||||
this.uploadTask = file.name
|
||||
|
||||
const config = {
|
||||
@ -466,7 +459,6 @@ export default {
|
||||
|
||||
async renameFile (evt) {
|
||||
evt.preventDefault()
|
||||
await this.$store.dispatch('auth/inspectToken')
|
||||
|
||||
await this.$axios.patch(
|
||||
'api/player/media/op/',
|
||||
@ -502,7 +494,6 @@ export default {
|
||||
},
|
||||
|
||||
async deleteFileOrFolder () {
|
||||
await this.$store.dispatch('auth/inspectToken')
|
||||
let file
|
||||
let pathName
|
||||
|
||||
|
@ -275,7 +275,6 @@ export default {
|
||||
|
||||
methods: {
|
||||
async getPreset (preset) {
|
||||
await this.$store.dispatch('auth/inspectToken')
|
||||
let req = ''
|
||||
|
||||
if (preset) {
|
||||
@ -316,7 +315,6 @@ export default {
|
||||
this.createPreset()
|
||||
},
|
||||
async createPreset () {
|
||||
await this.$store.dispatch('auth/inspectToken')
|
||||
const preset = {
|
||||
name: this.newPresetName,
|
||||
message: this.form.text,
|
||||
@ -346,7 +344,6 @@ export default {
|
||||
})
|
||||
},
|
||||
async savePreset () {
|
||||
await this.$store.dispatch('auth/inspectToken')
|
||||
if (this.selected) {
|
||||
const preset = {
|
||||
id: this.form.id,
|
||||
@ -383,7 +380,6 @@ export default {
|
||||
this.deletePreset()
|
||||
},
|
||||
async deletePreset () {
|
||||
await this.$store.dispatch('auth/inspectToken')
|
||||
if (this.selected) {
|
||||
await this.$axios.delete(`api/player/messenger/${this.form.id}/`)
|
||||
}
|
||||
@ -393,7 +389,6 @@ export default {
|
||||
},
|
||||
|
||||
async submitMessage () {
|
||||
await this.$store.dispatch('auth/inspectToken')
|
||||
function aToHex (num) {
|
||||
return '0x' + Math.round(num * 255).toString(16)
|
||||
}
|
||||
|
@ -335,7 +335,6 @@ export default {
|
||||
},
|
||||
|
||||
async created () {
|
||||
await this.getConfig()
|
||||
await this.getStatus()
|
||||
|
||||
this.extensions = this.configPlayout.storage.extensions.join(' ')
|
||||
@ -382,20 +381,12 @@ export default {
|
||||
},
|
||||
|
||||
methods: {
|
||||
async getConfig () {
|
||||
await this.$store.dispatch('auth/inspectToken')
|
||||
await this.$store.dispatch('config/getGuiConfig')
|
||||
await this.$store.dispatch('config/getPlayoutConfig')
|
||||
},
|
||||
async getPath (extensions, path) {
|
||||
this.isLoading = true
|
||||
await this.$store.dispatch('auth/inspectToken')
|
||||
await this.$store.dispatch('media/getTree', { extensions, path })
|
||||
this.isLoading = false
|
||||
},
|
||||
async getStatus () {
|
||||
await this.$store.dispatch('auth/inspectToken')
|
||||
|
||||
const status = await this.$axios.post('api/player/system/', { run: 'status' })
|
||||
|
||||
if (status.data.data && status.data.data === 'active') {
|
||||
@ -405,13 +396,11 @@ export default {
|
||||
}
|
||||
},
|
||||
async playoutControl (state) {
|
||||
await this.$store.dispatch('auth/inspectToken')
|
||||
await this.$axios.post('api/player/system/', { run: state })
|
||||
|
||||
setTimeout(() => { this.getStatus() }, 1000)
|
||||
},
|
||||
async getPlaylist () {
|
||||
await this.$store.dispatch('auth/inspectToken')
|
||||
await this.$store.dispatch('playlist/getPlaylist', { dayStart: this.configPlayout.playlist.day_start, date: this.listDate })
|
||||
},
|
||||
showModal (src) {
|
||||
@ -464,7 +453,6 @@ export default {
|
||||
await this.$store.dispatch('playlist/getPlaylist', { dayStart: this.configPlayout.playlist.day_start, date: this.listDate })
|
||||
},
|
||||
async savePlaylist () {
|
||||
await this.$store.dispatch('auth/inspectToken')
|
||||
this.$store.commit('playlist/UPDATE_PLAYLIST', this.$processPlaylist(
|
||||
this.configPlayout.playlist.day_start, this.playlist))
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
export default function ({ $axios, store, redirect }) {
|
||||
export default async function ({ $axios, store, redirect }) {
|
||||
await store.dispatch('auth/inspectToken')
|
||||
|
||||
$axios.onRequest((config) => {
|
||||
const token = store.state.auth.jwtToken
|
||||
if (token) {
|
||||
|
@ -62,10 +62,20 @@ export const actions = {
|
||||
refresh: state.jwtRefresh,
|
||||
progress: false
|
||||
}
|
||||
const response = await this.$axios.post('auth/token/refresh/', payload)
|
||||
|
||||
commit('UPADTE_TOKEN', { token: response.data.access })
|
||||
commit('UPDATE_IS_LOGIN', true)
|
||||
await this.$axios.post('auth/token/refresh/', payload)
|
||||
.then((response) => {
|
||||
commit('UPADTE_TOKEN', { token: response.data.access })
|
||||
commit('UPDATE_IS_LOGIN', true)
|
||||
})
|
||||
.catch((error) => {
|
||||
if (error.response.status === 401) {
|
||||
this.$cookies.remove('token')
|
||||
this.$cookies.remove('refresh')
|
||||
commit('UPADTE_TOKEN', { token: null, refresh: null })
|
||||
commit('UPDATE_IS_LOGIN', false)
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
async inspectToken ({ commit, dispatch, state }) {
|
||||
|
Loading…
Reference in New Issue
Block a user