• Aryan Noshirvnai's avatar
    Add real Telegram phone/code login, replacing the dev-only auto-auth gap · be345ade
    Aryan Noshirvnai authored
    Nothing but the dev account could ever use this app - ProtectedRoute and
    RequireRole just showed a static "not authenticated" message with no
    way forward. Adds a real two-step login screen (phone -> code, via the
    backend's existing /auth/request_code + /auth/login, unchanged) and
    wires it in as the actual destination: both guards now redirect to
    /login (preserving the originally-requested page via router state) and
    land back where the user was trying to go, matching a normal auth flow
    instead of a dead end.
    
    Also fixes a real race this surfaced during live testing: the dev-only
    auto-login bootstrap ran in a useEffect, which only fires *after* the
    first render. ProtectedRoute's brand-new <Navigate> redirect renders
    before that effect ever gets a chance to run, so isAuthenticated was
    still false on the very first paint - every fresh dev-mode load bounced
    through /login before the bootstrap could authenticate it, sometimes
    stranding the session there since flipping isAuthenticated true a
    moment later doesn't undo an already-completed redirect. Moved the
    bootstrap into the isAuthenticated state's lazy initializer instead, so
    it runs synchronously before the first render - the same reason a real
    user's already-stored token doesn't have this problem.
    Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
    Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
    be345ade
ProtectedRoute.test.tsx 1.35 KB