From fdfa38ac780990e866328d34bf3142af3da19f8c Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Sun, 28 Jun 2020 18:41:12 +0530 Subject: [PATCH] auth: wait for auto-discovery before showing view This partially reverts change from b194ad205b558803b7a1c0c8cc177e5b14e80835 which introduces loading of dashboard while auto-discovery takes place in background. The cons is that user will feel that login is taking time, but he'll be allowed to redirect to a page before session timeout/logout. In #456 a similar usability issue was added. However, a tab refresh will be faster because in b194ad205b558803b7a1c0c8cc177e5b14e80835 we've added support for using cached discovered APIs. Fixes #456 Signed-off-by: Rohit Yadav --- ui/src/permission.js | 4 ++-- ui/src/store/modules/user.js | 11 ++--------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/ui/src/permission.js b/ui/src/permission.js index 65fcb2be7f8..9fffb7cfda9 100644 --- a/ui/src/permission.js +++ b/ui/src/permission.js @@ -69,7 +69,7 @@ router.beforeEach((to, from, next) => { description: 'Exception caught while discoverying features' }) store.dispatch('Logout').then(() => { - next({ path: '/user/login' }) + next({ path: '/user/login', query: { redirect: to.fullPath } }) }) }) } else { @@ -80,7 +80,7 @@ router.beforeEach((to, from, next) => { if (whiteList.includes(to.name)) { next() } else { - next({ path: '/user/login' }) + next({ path: '/user/login', query: { redirect: to.fullPath } }) NProgress.done() } } diff --git a/ui/src/store/modules/user.js b/ui/src/store/modules/user.js index 6d24e5f6a70..4172eaf96f9 100644 --- a/ui/src/store/modules/user.js +++ b/ui/src/store/modules/user.js @@ -124,15 +124,7 @@ const user = { commit('SET_APIS', cachedApis) resolve(cachedApis) } else { - // This will show the dashboard and some common navigation sections - // to most users/roles, while we complete API autodiscovery - const apis = {} - apis.listUsers = {} - apis.listAccounts = {} - commit('SET_APIS', apis) - resolve(apis) - - const hide = message.loading('Discovering features...', 0) + const hide = message.loading('Discovering features, please wait...', 0) api('listApis').then(response => { const apis = {} const apiList = response.listapisresponse.api @@ -145,6 +137,7 @@ const user = { } } commit('SET_APIS', apis) + resolve(apis) store.dispatch('GenerateRoutes', { apis }).then(() => { router.addRoutes(store.getters.addRouters) })