aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--package.json2
-rw-r--r--src/router/index.ts3
-rw-r--r--src/views/LogIn.vue5
3 files changed, 6 insertions, 4 deletions
diff --git a/package.json b/package.json
index 63fbf4e..f190f42 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "openbills-web",
- "version": "0.4.0",
+ "version": "0.4.1",
"private": false,
"scripts": {
"dev": "vite",
diff --git a/src/router/index.ts b/src/router/index.ts
index 496f5d0..32a2962 100644
--- a/src/router/index.ts
+++ b/src/router/index.ts
@@ -85,8 +85,9 @@ const router = createRouter({
})
router.beforeEach((to, _, next) => {
+ console.log(to.fullPath)
if (to.meta.isAuth && !localStorage.getItem('authToken')) {
- next('/login?redirected=true')
+ next(`/login?redirect=${to.fullPath}`)
} else {
next()
}
diff --git a/src/views/LogIn.vue b/src/views/LogIn.vue
index 1b5f6c9..415c562 100644
--- a/src/views/LogIn.vue
+++ b/src/views/LogIn.vue
@@ -1,6 +1,6 @@
<script setup lang="js">
import { ref, toRaw } from 'vue'
-import { RouterLink, useRouter } from 'vue-router'
+import { RouterLink, useRoute, useRouter } from 'vue-router'
import axios from 'axios'
import { useToast } from 'vue-toast-notification'
@@ -8,6 +8,7 @@ const toast = useToast({
position: 'top-right'
})
+const route = useRoute()
const router = useRouter()
const storedEmail = sessionStorage.getItem('email')
@@ -30,7 +31,7 @@ const login = async (e) => {
localStorage.setItem('authToken', res.data.auth_token)
localStorage.setItem('refToken', res.data.refresh_token)
toast.default(`Welcome, ${res.data.data.Username}`)
- router.push({ path: '/' })
+ router.push({ path: route.query.redirect ? route.query.redirect : '/' })
} catch (err) {
const statusCode = err.request.status