From ef9b5a0bd79c9bcb17a09f78b918fd83349a2f5f Mon Sep 17 00:00:00 2001 From: rare-magma Date: Sun, 24 Oct 2021 14:02:05 +0200 Subject: [PATCH 1/5] feat: add disable authentication option --- .../SettingsModal/Tabs/Vuetorrent/General.vue | 21 +++++++++++++++++++ src/services/auth.js | 4 ++++ src/store/index.js | 1 + 3 files changed, 26 insertions(+) diff --git a/src/components/Modals/SettingsModal/Tabs/Vuetorrent/General.vue b/src/components/Modals/SettingsModal/Tabs/Vuetorrent/General.vue index 5bc44ba263..fb4078c28f 100644 --- a/src/components/Modals/SettingsModal/Tabs/Vuetorrent/General.vue +++ b/src/components/Modals/SettingsModal/Tabs/Vuetorrent/General.vue @@ -4,6 +4,19 @@ These settings are for the custom WebUI itself + + + + + + + @@ -172,6 +185,14 @@ export default { computed: { ...mapState(['webuiSettings']), ...mapGetters(['getAppVersion']), + disableAuthentication: { + get() { + return this.webuiSettings.disableAuthentication + }, + set(val) { + this.webuiSettings.disableAuthentication = val + } + }, freeSpace: { get() { return this.webuiSettings.showFreeSpace diff --git a/src/services/auth.js b/src/services/auth.js index dfae2e0dd8..bfcadfc9ed 100644 --- a/src/services/auth.js +++ b/src/services/auth.js @@ -1,5 +1,9 @@ import store from '../store' export function isAuthenticated() { + if (store.state.webuiSettings.disableAuthentication) { + return true + } + return store.state.authenticated } diff --git a/src/store/index.js b/src/store/index.js index 2b3a99275c..4501efb2a7 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -56,6 +56,7 @@ export default new Vuex.Store({ showSessionStat: true, showCurrentSpeed: true, showTrackerFilter: false, + disableAuthentication: false, showSpeedInTitle: false, deleteWithFiles: false, title: 'Default', From 6a20c96c5bef0b80ca38a400ba5c6b5314407057 Mon Sep 17 00:00:00 2001 From: rare-magma Date: Mon, 25 Oct 2021 19:27:23 +0200 Subject: [PATCH 2/5] fix: disable auth only if already authenticated --- src/services/auth.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/auth.js b/src/services/auth.js index bfcadfc9ed..0c10694aad 100644 --- a/src/services/auth.js +++ b/src/services/auth.js @@ -1,7 +1,7 @@ import store from '../store' export function isAuthenticated() { - if (store.state.webuiSettings.disableAuthentication) { + if (store.state.webuiSettings.disableAuthentication && store.state.authenticated) { return true } From 0c1e74e8f0c945659220c276c5713a8430db0c5c Mon Sep 17 00:00:00 2001 From: rare-magma Date: Mon, 25 Oct 2021 20:24:43 +0200 Subject: [PATCH 3/5] Revert "fix: disable auth only if already authenticated" This reverts commit 6a20c96c5bef0b80ca38a400ba5c6b5314407057. --- src/services/auth.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/auth.js b/src/services/auth.js index 0c10694aad..bfcadfc9ed 100644 --- a/src/services/auth.js +++ b/src/services/auth.js @@ -1,7 +1,7 @@ import store from '../store' export function isAuthenticated() { - if (store.state.webuiSettings.disableAuthentication && store.state.authenticated) { + if (store.state.webuiSettings.disableAuthentication) { return true } From e90e0ae40f6de82a35c634081932531b5ba84136 Mon Sep 17 00:00:00 2001 From: rare-magma Date: Sun, 31 Oct 2021 16:38:56 +0100 Subject: [PATCH 4/5] fix: serve login page only if needed --- src/App.vue | 17 ++++++++++++++++- src/services/auth.js | 4 ---- src/services/qbit.js | 5 +++++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/App.vue b/src/App.vue index 05b94e7174..374c0a3dc9 100644 --- a/src/App.vue +++ b/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.' diff --git a/src/services/auth.js b/src/services/auth.js index bfcadfc9ed..dfae2e0dd8 100644 --- a/src/services/auth.js +++ b/src/services/auth.js @@ -1,9 +1,5 @@ import store from '../store' export function isAuthenticated() { - if (store.state.webuiSettings.disableAuthentication) { - return true - } - return store.state.authenticated } diff --git a/src/services/qbit.js b/src/services/qbit.js index 2c3150e806..9fc9e4c836 100644 --- a/src/services/qbit.js +++ b/src/services/qbit.js @@ -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') } From f7d71156f839b9e65bfba5aec7dba78cb4a4caaf Mon Sep 17 00:00:00 2001 From: rare-magma Date: Sun, 31 Oct 2021 16:39:06 +0100 Subject: [PATCH 5/5] Revert "feat: add disable authentication option" This reverts commit ef9b5a0bd79c9bcb17a09f78b918fd83349a2f5f. --- .../SettingsModal/Tabs/Vuetorrent/General.vue | 21 ------------------- src/store/index.js | 1 - 2 files changed, 22 deletions(-) diff --git a/src/components/Modals/SettingsModal/Tabs/Vuetorrent/General.vue b/src/components/Modals/SettingsModal/Tabs/Vuetorrent/General.vue index fb4078c28f..5bc44ba263 100644 --- a/src/components/Modals/SettingsModal/Tabs/Vuetorrent/General.vue +++ b/src/components/Modals/SettingsModal/Tabs/Vuetorrent/General.vue @@ -4,19 +4,6 @@ These settings are for the custom WebUI itself - - - - - - - @@ -185,14 +172,6 @@ export default { computed: { ...mapState(['webuiSettings']), ...mapGetters(['getAppVersion']), - disableAuthentication: { - get() { - return this.webuiSettings.disableAuthentication - }, - set(val) { - this.webuiSettings.disableAuthentication = val - } - }, freeSpace: { get() { return this.webuiSettings.showFreeSpace diff --git a/src/store/index.js b/src/store/index.js index 4501efb2a7..2b3a99275c 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -56,7 +56,6 @@ export default new Vuex.Store({ showSessionStat: true, showCurrentSpeed: true, showTrackerFilter: false, - disableAuthentication: false, showSpeedInTitle: false, deleteWithFiles: false, title: 'Default',