From 9c0dca8f1375138083650503cd601c4f0bcb1223 Mon Sep 17 00:00:00 2001 From: Edd Date: Sun, 18 Jan 2026 01:37:27 +0000 Subject: [PATCH] forget and recover password functionalities --- app/app.vue | 6 ++ app/components/ui/toast/Toast.vue | 33 ++++++++ app/layouts/default.vue | 9 ++- app/middleware/guest.global.js | 20 +++++ app/pages/auth-test.vue | 84 -------------------- app/pages/auth/forgot-password.vue | 89 +++++++++++++++++++++ app/pages/auth/login.vue | 84 ++++++++++---------- app/pages/index.vue | 14 ++-- app/pages/profile/index.vue | 9 +-- app/pages/profile/update-password.vue | 108 ++++++++++++++++++++++++++ app/stores/notification-store.js | 22 ++++++ 11 files changed, 333 insertions(+), 145 deletions(-) create mode 100644 app/components/ui/toast/Toast.vue create mode 100644 app/middleware/guest.global.js delete mode 100644 app/pages/auth-test.vue create mode 100644 app/pages/auth/forgot-password.vue create mode 100644 app/pages/profile/update-password.vue create mode 100644 app/stores/notification-store.js diff --git a/app/app.vue b/app/app.vue index f8eacfa..fab1d78 100644 --- a/app/app.vue +++ b/app/app.vue @@ -1,5 +1,11 @@ + + diff --git a/app/components/ui/toast/Toast.vue b/app/components/ui/toast/Toast.vue new file mode 100644 index 0000000..e82e783 --- /dev/null +++ b/app/components/ui/toast/Toast.vue @@ -0,0 +1,33 @@ + + + + + \ No newline at end of file diff --git a/app/layouts/default.vue b/app/layouts/default.vue index b0fbd8d..018d133 100644 --- a/app/layouts/default.vue +++ b/app/layouts/default.vue @@ -40,22 +40,23 @@ onMounted(() => {
- diff --git a/app/middleware/guest.global.js b/app/middleware/guest.global.js new file mode 100644 index 0000000..71bb559 --- /dev/null +++ b/app/middleware/guest.global.js @@ -0,0 +1,20 @@ +export default defineNuxtRouteMiddleware((to, from) => { + const authStore = useAuthStore(); + const isLoggedIn = !!(authStore.user || authStore.token); + const mustChangePassword = authStore.user?.mustChangePassword === true; + + const isAuthPage = to.path.startsWith('/auth'); + const isUpdatePasswordPage = to.path === '/profile/update-password'; + + if (!isLoggedIn && !isAuthPage) { + return navigateTo('/auth/login'); + } + + if (isLoggedIn && mustChangePassword && !isUpdatePasswordPage) { + return navigateTo('/profile/update-password'); + } + + if (isLoggedIn && isAuthPage) { + return navigateTo('/'); + } +}); \ No newline at end of file diff --git a/app/pages/auth-test.vue b/app/pages/auth-test.vue deleted file mode 100644 index a4bf2ed..0000000 --- a/app/pages/auth-test.vue +++ /dev/null @@ -1,84 +0,0 @@ - - diff --git a/app/pages/auth/forgot-password.vue b/app/pages/auth/forgot-password.vue new file mode 100644 index 0000000..f032be0 --- /dev/null +++ b/app/pages/auth/forgot-password.vue @@ -0,0 +1,89 @@ + + + \ No newline at end of file diff --git a/app/pages/auth/login.vue b/app/pages/auth/login.vue index 545ad25..e8711ff 100644 --- a/app/pages/auth/login.vue +++ b/app/pages/auth/login.vue @@ -6,7 +6,7 @@
-

Login

+

Login

@@ -19,24 +19,29 @@ -

{{ errors.email }}

+ ]" placeholder="admin@mail.pt"> +

{{ errors.email }}

- -

{{ errors.password }}

+ ]" placeholder="••••••••" @keyup.enter="handleLogin"> +

{{ errors.password }}

-
- + + + Forgot Password? +
@@ -44,28 +49,6 @@ - + \ No newline at end of file diff --git a/app/pages/index.vue b/app/pages/index.vue index 9b7905c..64eaa22 100644 --- a/app/pages/index.vue +++ b/app/pages/index.vue @@ -4,7 +4,7 @@
-

+

Academic Management System

@@ -15,17 +15,17 @@