Refactor authentication handling in Navigation and registration components to support lazy store access, improving resilience against Pinia initialization issues. Enhance registration logic to include optional password fallback for passkey users, with validation checks for password strength and confirmation. Update server-side registration to handle optional password securely, ensuring consistent user experience across different authentication methods.
Some checks failed
Code Analysis (JS/Vue) / analyze (push) Failing after 49s
Some checks failed
Code Analysis (JS/Vue) / analyze (push) Failing after 49s
This commit is contained in:
@@ -851,17 +851,35 @@ import { useRoute } from 'vue-router'
|
||||
import { Menu, X, ChevronDown } from 'lucide-vue-next'
|
||||
|
||||
const route = useRoute()
|
||||
const authStore = useAuthStore()
|
||||
const isMobileMenuOpen = ref(false)
|
||||
const mobileSubmenu = ref(null)
|
||||
const mannschaften = ref([])
|
||||
const hasGalleryImages = ref(false)
|
||||
const showCmsDropdown = ref(false)
|
||||
|
||||
// Reactive auth state from store
|
||||
const isLoggedIn = computed(() => authStore.isLoggedIn)
|
||||
const isAdmin = computed(() => authStore.isAdmin)
|
||||
const canAccessNewsletter = computed(() => authStore.hasAnyRole('admin', 'vorstand', 'newsletter'))
|
||||
// Lazy store access to avoid Pinia initialization issues
|
||||
const getAuthStore = () => {
|
||||
try {
|
||||
return useAuthStore()
|
||||
} catch (e) {
|
||||
// Fallback if Pinia is not yet initialized
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
// Reactive auth state from store (lazy)
|
||||
const isLoggedIn = computed(() => {
|
||||
const store = getAuthStore()
|
||||
return store?.isLoggedIn ?? false
|
||||
})
|
||||
const isAdmin = computed(() => {
|
||||
const store = getAuthStore()
|
||||
return store?.isAdmin ?? false
|
||||
})
|
||||
const canAccessNewsletter = computed(() => {
|
||||
const store = getAuthStore()
|
||||
return store?.hasAnyRole('admin', 'vorstand', 'newsletter') ?? false
|
||||
})
|
||||
|
||||
// Automatisches Setzen des Submenus basierend auf der Route
|
||||
const currentSubmenu = computed(() => {
|
||||
@@ -954,7 +972,10 @@ const handleDocumentClick = (e) => {
|
||||
onMounted(() => {
|
||||
loadMannschaften()
|
||||
checkGalleryImages()
|
||||
authStore.checkAuth()
|
||||
const store = getAuthStore()
|
||||
if (store) {
|
||||
store.checkAuth()
|
||||
}
|
||||
|
||||
// Close CMS dropdown when clicking outside
|
||||
document.addEventListener('click', handleDocumentClick)
|
||||
|
||||
Reference in New Issue
Block a user