diff --git a/frontend/src/plugins/router/middlewares/login.ts b/frontend/src/plugins/router/middlewares/login.ts index 7e7bb98eb5c..caba14d0b59 100644 --- a/frontend/src/plugins/router/middlewares/login.ts +++ b/frontend/src/plugins/router/middlewares/login.ts @@ -22,25 +22,25 @@ export async function loginGuard( let destinationRoute: RouteLocationPathRaw | undefined; const jsonConfig = await getJSONConfig(); + if (!jsonConfig.allowServerSelection && (to.path === serverAddUrl || to.path === serverSelectUrl)) { + return false; + } + if (!isNil(remote.auth.currentServer) && !isNil(remote.auth.currentUser) && !isNil(remote.auth.currentUserToken) && routes.has(to.path)) { destinationRoute = { path: '/', replace: true }; - } else if (to.path === serverAddUrl && remote.auth.servers.length > 0 || to.path === serverSelectUrl) { - if (!jsonConfig.allowServerSelection) { - destinationRoute = { path: serverLoginUrl, replace: true }; - } } if (remote.auth.servers.length <= 0 && jsonConfig.defaultServerURLs.length <= 0) { destinationRoute = { path: serverAddUrl, replace: true }; } else if (!routes.has(to.path)) { if (isNil(remote.auth.currentServer)) { - if (jsonConfig.allowServerSelection) { - destinationRoute = { path: serverSelectUrl, replace: true }; - } else { + if (jsonConfig.defaultServerURLs.length) { await until(() => remote.auth.currentServer).toBeTruthy({ flush: 'pre' }); return loginGuard(to); } + + destinationRoute = { path: serverSelectUrl, replace: true }; } else if (isNil(remote.auth.currentUser)) { destinationRoute = { path: serverLoginUrl, replace: true }; }