From 2e58ce0d184d4f0d7bc568fd119aa57551556a8f Mon Sep 17 00:00:00 2001 From: cvium Date: Mon, 29 Mar 2021 20:41:50 +0200 Subject: [PATCH] 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()); } } }