This is an automated email from the ASF dual-hosted git repository.

jinsongzhou pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/amoro.git


The following commit(s) were added to refs/heads/master by this push:
     new b6b1e0f2e [Improvement] Redirect to login page if user doesn't login 
(#3274)
b6b1e0f2e is described below

commit b6b1e0f2e0e045c1679e38f9a2c7ade3349be637
Author: chouchouji <[email protected]>
AuthorDate: Mon Dec 2 16:24:39 2024 +0800

    [Improvement] Redirect to login page if user doesn't login (#3274)
    
    Co-authored-by: ZhouJinsong <[email protected]>
    Co-authored-by: baiyangtx <[email protected]>
    Co-authored-by: ConradJam <[email protected]>
---
 amoro-web/src/main.ts               | 13 +++++++------
 amoro-web/src/views/login/index.vue |  4 ++--
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/amoro-web/src/main.ts b/amoro-web/src/main.ts
index cc9d2047d..dd257eb2d 100644
--- a/amoro-web/src/main.ts
+++ b/amoro-web/src/main.ts
@@ -71,16 +71,17 @@ RegisterComponents(app);
   finally {
     const store = useStore()
     router.beforeEach((to: RouteLocationNormalized, from: 
RouteLocationNormalized, next: NavigationGuardNext) => {
-      if (to.fullPath === '/login') {
-        if (store.userInfo.userName) {
-          return next('/')
-        }
+      // if no username in store and not go to login page, should redirect to 
login page
+      if (!store.userInfo.userName && to.path !== '/login') {
         store.setHistoryPath({
           path: from.path,
-          query: { ...from.query },
+          query: from.query,
         })
+        next('/login')
+      }
+      else {
+        next()
       }
-      next()
     })
 
     app.use(router)
diff --git a/amoro-web/src/views/login/index.vue 
b/amoro-web/src/views/login/index.vue
index 4818d09d9..8092322d8 100644
--- a/amoro-web/src/views/login/index.vue
+++ b/amoro-web/src/views/login/index.vue
@@ -18,7 +18,7 @@ limitations under the License.
 
 <script lang="ts">
 import { message } from 'ant-design-vue'
-import { computed, defineComponent, onMounted, reactive } from 'vue'
+import { computed, defineComponent, reactive } from 'vue'
 import { useRouter } from 'vue-router'
 import loginService from '@/services/login.service'
 import { usePlaceholder } from '@/hooks/usePlaceholder'
@@ -63,7 +63,7 @@ export default defineComponent({
     const disabled = computed(() => {
       return !(formState.username && formState.password)
     })
-    onMounted(() => {})
+
     return {
       placeholder,
       formState,

Reply via email to