Navigation Menu

Skip to content

Commit

Permalink
feat: bypass authentication (#310)
Browse files Browse the repository at this point in the history
  • Loading branch information
rare-magma committed Nov 1, 2021
1 parent c6fff2c commit b069ce4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/App.vue
Expand Up @@ -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.'
Expand Down
5 changes: 5 additions & 0 deletions src/services/qbit.js
Expand Up @@ -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')
}
Expand Down

0 comments on commit b069ce4

Please sign in to comment.