- Added support for generating Android access tokens and managing refresh sessions in the auth endpoints. - Implemented new tests for login, logout, and refresh functionalities specific to Android clients. - Enhanced password reset logging with normalization and masking of email addresses. - Created a new diagnostics endpoint for password reset attempts, including filtering and summarizing logs. - Introduced a new utility for managing password reset logs with retention policies. - Added tests for password reset log utilities to ensure proper functionality and privacy compliance. - Updated WebAuthn configuration tests to validate origin handling for production and allowed origins.
49 lines
1.7 KiB
JavaScript
49 lines
1.7 KiB
JavaScript
export default defineNuxtRouteMiddleware(async (to, _from) => {
|
|
// Check if route requires auth
|
|
const protectedRoutes = ['/mitgliederbereich', '/cms']
|
|
const requiresAuth = protectedRoutes.some(route => to.path.startsWith(route))
|
|
|
|
if (!requiresAuth) {
|
|
return
|
|
}
|
|
|
|
// Check auth status
|
|
try {
|
|
const { data: auth } = await useFetch('/api/auth/status')
|
|
|
|
if (!auth.value || !auth.value.isLoggedIn) {
|
|
return navigateTo('/login?redirect=' + to.path)
|
|
}
|
|
|
|
// Check role for CMS
|
|
if (to.path.startsWith('/cms')) {
|
|
const roles = auth.value.roles || (auth.value.role ? [auth.value.role] : [])
|
|
const hasAccess = roles.includes('admin') || roles.includes('vorstand') || roles.includes('newsletter')
|
|
const canAccessContactRequests = roles.includes('admin') || roles.includes('vorstand') || roles.includes('trainer')
|
|
|
|
// Newsletter-Seite nur für Newsletter-Rolle, Admin oder Vorstand
|
|
if (to.path.startsWith('/cms/newsletter')) {
|
|
if (!hasAccess) {
|
|
return navigateTo('/mitgliederbereich')
|
|
}
|
|
} else if (to.path.startsWith('/cms/passwort-reset-diagnose')) {
|
|
if (!roles.includes('admin')) {
|
|
return navigateTo('/cms')
|
|
}
|
|
} else if (to.path.startsWith('/cms/kontaktanfragen')) {
|
|
if (!canAccessContactRequests) {
|
|
return navigateTo('/mitgliederbereich')
|
|
}
|
|
} else {
|
|
// Andere CMS-Seiten nur für Admin oder Vorstand
|
|
const isAdmin = roles.includes('admin') || roles.includes('vorstand')
|
|
if (!isAdmin) {
|
|
return navigateTo('/mitgliederbereich')
|
|
}
|
|
}
|
|
}
|
|
} catch (_error) {
|
|
return navigateTo('/login?redirect=' + to.path)
|
|
}
|
|
})
|