From d47b17f575524a043082d621cc4bc74aff8da953 Mon Sep 17 00:00:00 2001 From: Cindy Chang Date: Fri, 14 Jun 2024 11:30:43 +0800 Subject: [PATCH] fix #301 should push to "/files" --- src/stores/login.js | 3 +-- src/views/Login/index.vue | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/stores/login.js b/src/stores/login.js index f7ecb6a..83c874f 100644 --- a/src/stores/login.js +++ b/src/stores/login.js @@ -35,7 +35,6 @@ export default defineStore('loginStore', { const response = await axios.post(api, this.auth, config); const accessToken = response.data.access_token; const refreshToken = response.data.refresh_token; - // 將 token 儲存在 cookie document.cookie = `luciaToken=${accessToken}`; // document.cookie = `luciaRefreshToken=${refreshToken};expires=${new Date(this.expired)};`; @@ -48,7 +47,7 @@ export default defineStore('loginStore', { if(this.rememberedReturnToUrl !== "") { window.location.href = atob(this.rememberedReturnToUrl); } else { - this.$router.push('/login'); + this.$router.push('/files'); } } catch(error) { this.isInvalid = true; diff --git a/src/views/Login/index.vue b/src/views/Login/index.vue index ba4f267..5dff2bd 100644 --- a/src/views/Login/index.vue +++ b/src/views/Login/index.vue @@ -106,7 +106,9 @@ export default { created() { // 考慮到使用者可能在未登入的情況下貼入一個頁面網址連結過來瀏覽器 // btoa: 對字串進行 Base64 編碼 - this.setRememberedReturnToUrl(btoa(this.$route.query['return-to'])); + if(this.$route.query['return-to']) { + this.setRememberedReturnToUrl(btoa(this.$route.query['return-to'])); + } }, };