feat(auth): Implementazione completa sistema autenticazione
BREAKING CHANGE: Tutte le pagine ora richiedono autenticazione Nuove funzionalità: - Sistema di login con password hardcoded (admin123) - Form di login full-screen con gradiente viola - Protezione automatica di tutte le route - Pulsante logout visibile in tutte le pagine - Gestione thread-safe eventi autenticazione con InvokeAsync() Componenti: - AuthenticationService: servizio Singleton per gestione stato - Login.razor: pagina login con validazione e messaggi errore - App.razor: routing condizionale basato su autenticazione - MainLayout.razor: pulsante logout integrato Fix tecnici: - Risolto errore "Dispatcher not associated" usando InvokeAsync() - Implementato pattern corretto per eventi cross-thread in Blazor Server - Aggiunto Dispose per prevenire memory leak
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
# ✅ Fix Applicato: Errore Dispatcher Login/Logout
|
||||
|
||||
## 🐛 Problema
|
||||
Errore intermittente durante login/logout:
|
||||
```
|
||||
System.InvalidOperationException: 'The current thread is not associated with the Dispatcher.
|
||||
Use InvokeAsync() to switch execution to the Dispatcher...'
|
||||
```
|
||||
|
||||
## ✅ Soluzione
|
||||
Modificato `App.razor` per usare `InvokeAsync()` per aggiornamenti UI thread-safe.
|
||||
|
||||
## 📝 Codice Modificato
|
||||
|
||||
### PRIMA (❌ Non Thread-Safe)
|
||||
```csharp
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
AuthService.OnAuthenticationStateChanged += StateHasChanged; // ❌
|
||||
}
|
||||
```
|
||||
|
||||
### DOPO (✅ Thread-Safe)
|
||||
```csharp
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
AuthService.OnAuthenticationStateChanged += OnAuthenticationStateChanged; // ✅
|
||||
}
|
||||
|
||||
private void OnAuthenticationStateChanged()
|
||||
{
|
||||
InvokeAsync(StateHasChanged); // ✅ Thread-safe
|
||||
}
|
||||
```
|
||||
|
||||
## 🎯 Risultato
|
||||
- ✅ Nessun errore durante login
|
||||
- ✅ Nessun errore durante logout
|
||||
- ✅ Aggiornamenti UI fluidi e thread-safe
|
||||
- ✅ Comportamento stabile e prevedibile
|
||||
|
||||
## 📁 File Modificato
|
||||
- `Data_Coupler\App.razor`
|
||||
|
||||
## 📚 Documentazione
|
||||
- Dettagli completi: `FIX_LOGIN_DISPATCHER_ERROR.md`
|
||||
- Documentazione aggiornata: `SISTEMA_LOGIN.md`
|
||||
|
||||
---
|
||||
**Status**: ✅ RISOLTO
|
||||
**Data**: 8 Ottobre 2025
|
||||
Reference in New Issue
Block a user