Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ function AppRoutes() {
isAuthenticated ? <Navigate to='/startDebate' replace /> : <Home />
}
/>
<Route path='/auth' element={<Authentication />} />
<Route path='/auth'
element={ isAuthenticated ? <Navigate to='/startDebate' replace/> : <Authentication/> }
/>
Comment on lines +62 to +64

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== files =="
git ls-files | grep -E '(^|/)frontend/src/App\.tsx$|AuthProvider|AuthContext|Route|Authentication' | sed -n '1,120p'

echo "== App.tsx outline/sections =="
wc -l frontend/src/App.tsx
sed -n '1,130p' frontend/src/App.tsx

echo "== auth symbols =="
rg -n "AuthProvider|authContext|isAuthenticated|loading|Authentication|ProtectedRoute|startDebate|auth" frontend/src -S | sed -n '1,240p'

Repository: AOSSIE-Org/DebateAI

Length of output: 23230


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== authContext.tsx first 220 lines =="
sed -n '1,220p' frontend/src/context/authContext.tsx | cat -n

echo "== authContext.tsx later relevant lines =="
sed -n '220,370p' frontend/src/context/authContext.tsx | cat -n

echo "== package deps for React/Router =="
if [ -f frontend/package.json ]; then sed -n '1,140p' frontend/package.json; fi

echo "== local react-router-dom version lock if present =="
fd -a 'package-lock.json|pnpm-lock.yaml|yarn.lock|bun.lockb' frontend . | sed -n '1,40p'

Repository: AOSSIE-Org/DebateAI

Length of output: 17354


Show a loading state while restoring the auth token.

AuthProvider reads token from localStorage first, so on app start any valid token renders as isAuthenticated === true before verifyToken() settles. If a user lands on /auth and has a stored token, they get the login UI briefly instead of staying in auth-pending and then navigating to /startDebate. Set loading during token verification and gate /auth on that state before showing Authentication.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/src/App.tsx` around lines 62 - 64, Update the /auth route element to
use AuthProvider’s token-verification loading state before rendering
Authentication: keep the pending state visible while verifyToken() settles, then
navigate authenticated users to /startDebate and show Authentication only for
unauthenticated users. Locate the relevant loading state and verification flow
in AuthProvider and apply the gate in the Route definition.

<Route path='/admin/login' element={<AdminSignup />} />
<Route path='/admin/dashboard' element={<AdminDashboard />} />
{/* Public routes with layout */}
Expand Down