Refactor authentication middleware to remove dependency on Pinia, implementing direct API calls for authentication status checks. Update member API documentation to escape JWT token placeholder for clarity. Update session and user data formats for improved security and consistency.
Some checks failed
Code Analysis (JS/Vue) / analyze (push) Failing after 53s
Some checks failed
Code Analysis (JS/Vue) / analyze (push) Failing after 53s
This commit is contained in:
@@ -1,21 +1,20 @@
|
|||||||
export default defineNuxtRouteMiddleware(async (to, _from) => {
|
export default defineNuxtRouteMiddleware(async (to, _from) => {
|
||||||
// Only run on client-side
|
|
||||||
if (process.server) return
|
|
||||||
|
|
||||||
const authStore = useAuthStore()
|
|
||||||
|
|
||||||
// Check if route requires authentication
|
// Check if route requires authentication
|
||||||
const requiresAuth = to.meta.middleware === 'auth'
|
const mw = to.meta.middleware
|
||||||
|
const requiresAuth =
|
||||||
|
mw === 'auth' || (Array.isArray(mw) && mw.includes('auth'))
|
||||||
|
|
||||||
if (requiresAuth) {
|
if (requiresAuth) {
|
||||||
// Check auth status if not already checked
|
// Nicht auf Pinia angewiesen sein (sonst "no active Pinia" in manchen Nuxt-Lifecycle-Phasen)
|
||||||
if (!authStore.isLoggedIn) {
|
try {
|
||||||
await authStore.checkAuth()
|
const { data: auth } = await useFetch('/api/auth/status')
|
||||||
|
if (!auth.value || !auth.value.isLoggedIn) {
|
||||||
|
const redirect = encodeURIComponent(to.fullPath || to.path || '/')
|
||||||
|
return navigateTo(`/login?redirect=${redirect}`)
|
||||||
}
|
}
|
||||||
|
} catch (_e) {
|
||||||
// Redirect to login if not authenticated
|
const redirect = encodeURIComponent(to.fullPath || to.path || '/')
|
||||||
if (!authStore.isLoggedIn) {
|
return navigateTo(`/login?redirect=${redirect}`)
|
||||||
return navigateTo('/login')
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -540,7 +540,7 @@ curl -X POST http://localhost:3100/api/auth/login \
|
|||||||
|
|
||||||
# Mitglied hinzufügen mit Token
|
# Mitglied hinzufügen mit Token
|
||||||
curl -X POST http://localhost:3100/api/members \
|
curl -X POST http://localhost:3100/api/members \
|
||||||
-H "Authorization: Bearer <your-jwt-token>" \
|
-H "Authorization: Bearer <your-jwt-token>" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d '{
|
-d '{
|
||||||
"firstName": "Max",
|
"firstName": "Max",
|
||||||
@@ -552,7 +552,7 @@ curl -X POST http://localhost:3100/api/members \
|
|||||||
|
|
||||||
# Bulk-Import von Mitgliedern
|
# Bulk-Import von Mitgliedern
|
||||||
curl -X POST http://localhost:3100/api/members/bulk \
|
curl -X POST http://localhost:3100/api/members/bulk \
|
||||||
-H "Authorization: Bearer <your-jwt-token>" \
|
-H "Authorization: Bearer <your-jwt-token>" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d '{
|
-d '{
|
||||||
"members": [
|
"members": [
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
|
|||||||
CyRDzIKS5Ou7WW0Ri1r4G7yGBFv1MwyJUsdJYNUI2gx7KJ5Mr4d8JBe4YQ+vQlpFw/ZEhrBLXjsKwbEIMlmO/xZWln9TsE/1s9rwCd9WoCWrXOlSqQc6kWP6xJuoy0tXRBCGfEPqoIg/x/G/QsN0kIdnWPETOqOd9p9nc/OsmbhXHTGIUa2KKDNsk5JMJVRI1IUt8CzdpXQUQpbSBA8AgBV7sUiePWXlbqxfoWC7leV8oRWcgTz1Y0hKVB/yczjPUQP7hEI7GZ9O/2fysrTRPa5JtmwQ4CbfXe1wWANmxrIsUf1n/+yogcVfkG+Ld6YjhCnh1hmDQFEh7RkSB8J9uknvlrk/uXsnwRP55jBeum0ujsOaxisagJ1oniCVg27r2+fx0qiAIQDv5pVDp+EWkDMo4Wkw4qis6HwA46hy4ex22O4As550xhnomHq/Rtk6mO20Srlt+7dbUcopvVZn/ekXzL8ovzYFHA978B63m2Vt6m7wYdGduSjUChzXXcRUJwF2JKnOiSym2/zQ9EJi8UFBMgS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