Authentication
Authentication Flows
The application supports distinct login flows for Users and Administrators, along with a comprehensive registration process.
Login Pages
- User Login (
/login): Standard email/password login for voters. - Admin Login (
/admin-login): Dedicated login portal for system administrators.
Both forms use the AuthContext to store the received JWT and user details upon successful authentication.
Registration
The Registration page (/register) is a multi-step form that captures:
- Personal Details: Name, Email, Phone, DOB, Gender.
- Address: Full address details.
- Identity Verification:
- Aadhar Number
- Voter ID Number
- Profile Photo: Users must provide a photo for future face verification.
Route Protection
The PrivateRoute component ensures security by checking:
- Is Authenticated: Is there a valid JWT?
- Role Authorization: Does the user have the required role (
USERorADMIN) for the requested route?
If checks fail, the user is redirected to the appropriate login page.