-
Notifications
You must be signed in to change notification settings - Fork 36
feat: Connect React Frontend Authentication UI to Spring Boot JWT Backend API #70
Copy link
Copy link
Open
Description
🐛 Problem Statement
The React frontend includes authentication UI components (login,
password reset flow) and Axios is set up for API communication,
but these are not yet connected to the Spring Boot JWT backend.
Users currently cannot log in, obtain tokens, or reset passwords
through the frontend. This is a critical blocker for any
user-facing functionality in GreenCode.
📋 Background
The backend already provides:
- JWT/OAuth authentication endpoints
- Swagger/OpenAPI documentation at
/api/docs - Centralised configuration via
config/and.env
The frontend already has:
- Login and password reset UI components in
greencode-frontend/ - Axios installed for HTTP communication
- React Router for navigation
- Tailwind CSS for styling
These two layers need to be connected through a clean,
secure authentication flow.
✅ Acceptance Criteria
- Login form submits credentials to Spring Boot JWT endpoint
- JWT access token is stored securely (httpOnly cookie or
memory — not localStorage) - Axios instance includes Authorization header on
all authenticated requests - Password reset flow calls the backend reset API correctly
- Token refresh logic handles expired access tokens
- Protected React routes redirect unauthenticated users to login
- Error messages display correctly for invalid credentials
- Logout clears token and redirects to login page
- All auth flows tested with unit and integration tests
🔧 Suggested Approach
- Create an
authService.jsingreencode-frontend/src/services/
to handle login, logout, and token refresh calls - Configure a shared Axios instance with interceptors for
token injection and 401 handling - Implement a React Context (
AuthContext) to manage
auth state globally - Add protected route wrapper component using React Router
- Wire login and password reset forms to
authService.js - Test all flows end-to-end via Swagger docs
📁 Files Likely Affected
greencode-frontend/src/services/authService.js— new auth servicegreencode-frontend/src/context/AuthContext.jsx— new auth contextgreencode-frontend/src/api/axiosInstance.js— Axios configgreencode-frontend/src/components/Login.jsx— wire up formgreencode-frontend/src/components/PasswordReset.jsx— wire up formgreencode-frontend/src/routes/ProtectedRoute.jsx— new guardgreencode-frontend/src/App.jsx— wrap routes with auth contextdocs/— update authentication documentation
🏷️ Labels
enhancement frontend authentication backend-integration
📌 Milestone
v1.0 — Full Stack Integration
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels