Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add disable authentication option #310

Merged
merged 5 commits into from Nov 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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