Fix login issue where users are incorrectly shown as guests

Adjust initial state and effect for PassportApp's mode to correctly handle authentication status, preventing an immediate reset to login mode after successful authentication.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 279f1558-c0e3-40e4-8217-be7e9f4c6eca
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: 5e981d2c-3a05-4456-83a5-c8477fb3f0a8
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/b984cb14-1d19-4944-922b-bc79e821ed35/279f1558-c0e3-40e4-8217-be7e9f4c6eca/I1D3tV4
Replit-Helium-Checkpoint-Created: true
This commit is contained in:
sirpiglr 2025-12-21 04:30:42 +00:00
parent 35c796c08f
commit d7a76b5bac

View file

@ -2794,7 +2794,9 @@ function TerminalApp() {
function PassportApp({ onLoginSuccess, isDesktopLocked }: { onLoginSuccess?: () => void; isDesktopLocked?: boolean }) {
const { user, isAuthenticated, login, signup, logout } = useAuth();
const [mode, setMode] = useState<'view' | 'login' | 'signup'>('view');
const [mode, setMode] = useState<'view' | 'login' | 'signup'>(() =>
isDesktopLocked && !isAuthenticated ? 'login' : 'view'
);
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const [username, setUsername] = useState('');
@ -2817,10 +2819,10 @@ function PassportApp({ onLoginSuccess, isDesktopLocked }: { onLoginSuccess?: ()
}, [isAuthenticated, isDesktopLocked, onLoginSuccess]);
useEffect(() => {
if (!isAuthenticated && isDesktopLocked) {
setMode('login');
if (isAuthenticated) {
setMode('view');
}
}, [isAuthenticated, isDesktopLocked]);
}, [isAuthenticated]);
const handleLogin = async (e: React.FormEvent) => {
e.preventDefault();