User story
As a user, I want login errors and access decisions to be handled securely so that untrusted input cannot execute code and only authorized users can access administrative features.
Context
The frontend currently renders the login error query parameter with dangerouslySetInnerHTML in frontend/src/components/Login.tsx. Authentication and admin status are also currently determined client-side in frontend/src/context/AuthContext.tsx, where any non-empty credentials succeed and an @github.com address receives admin access.
Acceptance criteria
Implementation notes
- Update
frontend/src/components/Login.tsx to render error text safely and add a regression test for malicious query parameters.
- Trace the existing API authentication contract under
api/src before changing the frontend auth state.
- Update
frontend/src/context/AuthContext.tsx to use server-backed authentication, represent loading/error state, and clear state on logout or session failure.
- Keep the route guard in
frontend/src/components/admin/AdminProducts.tsx, but make it depend on server-backed auth state.
- Verify API routes enforce authorization independently of frontend navigation.
Scope
Included: login error rendering and authentication/authorization correctness.
Excluded: unrelated visual redesign, broad dependency upgrades, and general XSS auditing outside the login flow.
User story
As a user, I want login errors and access decisions to be handled securely so that untrusted input cannot execute code and only authorized users can access administrative features.
Context
The frontend currently renders the login
errorquery parameter withdangerouslySetInnerHTMLinfrontend/src/components/Login.tsx. Authentication and admin status are also currently determined client-side infrontend/src/context/AuthContext.tsx, where any non-empty credentials succeed and an@github.comaddress receives admin access.Acceptance criteria
dangerouslySetInnerHTMLis removed from the login flow.errorquery parameter containing HTML or script markup is displayed inertly.@github.comemail address./admin/products.Implementation notes
frontend/src/components/Login.tsxto render error text safely and add a regression test for malicious query parameters.api/srcbefore changing the frontend auth state.frontend/src/context/AuthContext.tsxto use server-backed authentication, represent loading/error state, and clear state on logout or session failure.frontend/src/components/admin/AdminProducts.tsx, but make it depend on server-backed auth state.Scope
Included: login error rendering and authentication/authorization correctness.
Excluded: unrelated visual redesign, broad dependency upgrades, and general XSS auditing outside the login flow.