mirror of
https://github.com/VueTorrent/VueTorrent.git
synced 2025-02-18 00:02:02 +03:00
feat: bypass authentication (#310)
This commit is contained in:
parent
c6fff2c644
commit
b069ce490e
2 changed files with 21 additions and 1 deletions
17
src/App.vue
17
src/App.vue
|
@ -49,9 +49,24 @@ export default {
|
|||
}())
|
||||
})
|
||||
this.$store.commit('SET_APP_VERSION', process.env['APPLICATION_VERSION'])
|
||||
this.checkAuthenticated()
|
||||
const needsAuth = this.needsAuthentication()
|
||||
if (needsAuth) {
|
||||
this.checkAuthenticated()
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async needsAuthentication() {
|
||||
const res = qbit.getAuthenticationStatus()
|
||||
const forbidden = res === 'Forbidden'
|
||||
if (forbidden) {
|
||||
return true
|
||||
} else {
|
||||
this.$store.commit('LOGIN', true)
|
||||
this.$store.commit('updateMainData')
|
||||
}
|
||||
|
||||
return false
|
||||
},
|
||||
async checkAuthenticated() {
|
||||
const res = await qbit.login()
|
||||
const authenticated = res === 'Ok.'
|
||||
|
|
|
@ -39,6 +39,11 @@ class Qbit {
|
|||
return data
|
||||
}
|
||||
|
||||
async getAuthenticationStatus() {
|
||||
return this.axios.get('/app/version')
|
||||
.then(response => response.statusText)
|
||||
}
|
||||
|
||||
async logout() {
|
||||
this.axios.post('/auth/logout')
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue