feat: bypass authentication (#310)

This commit is contained in:
Nuno 2021-11-01 14:27:50 +01:00 committed by GitHub
parent c6fff2c644
commit b069ce490e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 1 deletions

View file

@ -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.'

View file

@ -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')
}