From 2e58ce0d184d4f0d7bc568fd119aa57551556a8f Mon Sep 17 00:00:00 2001 From: cvium Date: Mon, 29 Mar 2021 20:41:50 +0200 Subject: [PATCH 1/3] fix: redirect to login if stored credentials are invalid --- src/components/appRouter.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/components/appRouter.js b/src/components/appRouter.js index f7b41d77ff..514dedc714 100644 --- a/src/components/appRouter.js +++ b/src/components/appRouter.js @@ -424,15 +424,20 @@ class AppRouter { onRequestFail(e, data) { const apiClient = this; - - if (data.status === 403) { + + // 401 means the credentials are broken + if (data.status === 401) { + console.debug('Invalid stored credentials, redirecting to login'); + appRouter.showLocalLogin(apiClient.serverId()); + } + else if (data.status === 403) { if (data.errorCode === 'ParentalControl') { const isCurrentAllowed = this.currentRouteInfo ? (this.currentRouteInfo.route.anonymous || this.currentRouteInfo.route.startup) : true; // Bounce to the login screen, but not if a password entry fails, obviously if (!isCurrentAllowed) { - this.showForcedLogoutMessage(globalize.translate('AccessRestrictedTryAgainLater')); - this.showLocalLogin(apiClient.serverId()); + appRouter.showForcedLogoutMessage(globalize.translate('AccessRestrictedTryAgainLater')); + appRouter.showLocalLogin(apiClient.serverId()); } } } From 24f6d88308913ad7cc53fa16ff73e5b844c09fe8 Mon Sep 17 00:00:00 2001 From: cvium Date: Mon, 29 Mar 2021 20:51:41 +0200 Subject: [PATCH 2/3] please mr linter --- src/components/appRouter.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/components/appRouter.js b/src/components/appRouter.js index 514dedc714..400c615d1d 100644 --- a/src/components/appRouter.js +++ b/src/components/appRouter.js @@ -424,13 +424,12 @@ class AppRouter { onRequestFail(e, data) { const apiClient = this; - + // 401 means the credentials are broken if (data.status === 401) { console.debug('Invalid stored credentials, redirecting to login'); appRouter.showLocalLogin(apiClient.serverId()); - } - else if (data.status === 403) { + } else if (data.status === 403) { if (data.errorCode === 'ParentalControl') { const isCurrentAllowed = this.currentRouteInfo ? (this.currentRouteInfo.route.anonymous || this.currentRouteInfo.route.startup) : true; From b50c06b0f52ee59319d99bad5219ed5544c1ceab Mon Sep 17 00:00:00 2001 From: cvium Date: Mon, 29 Mar 2021 21:29:59 +0200 Subject: [PATCH 3/3] this should be appRouter --- src/components/appRouter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/appRouter.js b/src/components/appRouter.js index 400c615d1d..7be3f652bd 100644 --- a/src/components/appRouter.js +++ b/src/components/appRouter.js @@ -431,7 +431,7 @@ class AppRouter { appRouter.showLocalLogin(apiClient.serverId()); } else if (data.status === 403) { if (data.errorCode === 'ParentalControl') { - const isCurrentAllowed = this.currentRouteInfo ? (this.currentRouteInfo.route.anonymous || this.currentRouteInfo.route.startup) : true; + const isCurrentAllowed = appRouter.currentRouteInfo ? (appRouter.currentRouteInfo.route.anonymous || appRouter.currentRouteInfo.route.startup) : true; // Bounce to the login screen, but not if a password entry fails, obviously if (!isCurrentAllowed) {