From b962a21b15e3d80d4d2132df76ca31bc41eb2fc9 Mon Sep 17 00:00:00 2001
From: Vidhu Kant Sharma <vidhukant@vidhukant.com>
Date: Thu, 7 Dec 2023 16:43:22 +0530
Subject: redirecting after login

---
 src/views/LogIn.vue | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

(limited to 'src/views/LogIn.vue')

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
 
-- 
cgit v1.2.3

