diff --git a/src/components/layout/AppHeader.tsx b/src/components/layout/AppHeader.tsx index ffe71ce..4025b25 100644 --- a/src/components/layout/AppHeader.tsx +++ b/src/components/layout/AppHeader.tsx @@ -45,7 +45,7 @@ export const AppHeader: React.FC = ({ onNavigate('/login'); }; - const initial = currentSession?.fullName?.trim().slice(0, 1) || 'د'; + const initial = currentSession?.fullName?.trim().slice(0, 1) || 'ر'; // Alerts are the critical items in the nearest horizon, not a fixed list. const alerts = items diff --git a/src/services/authService.ts b/src/services/authService.ts index 9251af5..2f5da1e 100644 --- a/src/services/authService.ts +++ b/src/services/authService.ts @@ -1,6 +1,6 @@ import { UserSession, PersonaType } from '../types/futures'; -const AUTH_STORAGE_KEY = 'ufr_auth_session_v1'; +const AUTH_STORAGE_KEY = 'ufr_auth_session_v2'; export const PRESET_USERS: Record = { president: { @@ -55,9 +55,21 @@ class AuthService { private loadSession() { try { + // Clear legacy storage keys if present + if (typeof window !== 'undefined' && window.localStorage) { + localStorage.removeItem('ufr_auth_session_v1'); + } + const stored = localStorage.getItem(AUTH_STORAGE_KEY); if (stored) { - this.currentSession = JSON.parse(stored); + const parsed = JSON.parse(stored); + if (parsed?.fullName && (parsed.fullName.includes('هرسیج') || parsed.fullName.includes('حسن') || parsed.fullName.includes('حسین'))) { + const role = (parsed.role as PersonaType) || 'president'; + this.currentSession = PRESET_USERS[role] || PRESET_USERS.president; + this.saveSession(); + } else { + this.currentSession = parsed; + } } else { // Default authenticated persona for immediate institutional exploration this.currentSession = PRESET_USERS.president;