Add member profile page with editable fields and password change
This commit is contained in:
22
middleware/auth.global.js
Normal file
22
middleware/auth.global.js
Normal file
@@ -0,0 +1,22 @@
|
||||
export default defineNuxtRouteMiddleware(async (to, from) => {
|
||||
// Only run on client-side
|
||||
if (process.server) return
|
||||
|
||||
const authStore = useAuthStore()
|
||||
|
||||
// Check if route requires authentication
|
||||
const requiresAuth = to.meta.middleware === 'auth'
|
||||
|
||||
if (requiresAuth) {
|
||||
// Check auth status if not already checked
|
||||
if (!authStore.isLoggedIn) {
|
||||
await authStore.checkAuth()
|
||||
}
|
||||
|
||||
// Redirect to login if not authenticated
|
||||
if (!authStore.isLoggedIn) {
|
||||
return navigateTo('/login')
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user