Overview
The Equestrian School Management System uses a role-based authentication system with email whitelisting for user registration.Authentication System
Authentication Method
The system uses Basic Authentication with the following flow:- User enters username and password
- Credentials are Base64 encoded
- Sent with
Authorization: Basic <encoded>header - Backend validates credentials
- Session stored in
sessionStorage
src/services/authService.ts:54-60)
Session Management
Storage Method:sessionStorage (browser-based)
Stored Data:
- Authentication credentials (Base64 encoded)
- User profile (without password)
- Active until browser close
- 15-minute idle timeout
- Manual logout available
src/components/auth/IdleHandler.tsx:21)
User Registration
Registration Flow
Users can register through the registration page (/register).
Registration Form Fields
Username for loginValidation: Cannot be empty
Email address (must be whitelisted)Validation:
- Valid email format
- Must be in whitelist
- Cannot be empty
User passwordRequirements:
- Minimum 8 characters
- Strength indicator shows:
- Weak (< 40%): Basic password
- Regular (40-80%): Moderate password
- Strong (> 80%): Complex password
Password confirmationValidation: Must match password field
Password Strength Calculation
(src/pages/Register.tsx:37-45)
- 8+ characters: +20%
- 12+ characters: +20%
- Mixed case letters: +20%
- Contains numbers: +20%
- Special characters: +20%
Email Whitelist
Only approved emails can register (src/pages/Register.tsx:47-57):
GET /auth/check-email/:email
User Login
Login Flow
Login Form Fields
User’s username
User’s passwordFeatures:
- Toggle visibility with eye icon
- Masked by default
- Auto-complete support
Login Implementation
(src/pages/Login.tsx:34-68)
Protected Routes
All application routes (except/login and /register) are protected.
Implementation: (src/components/auth/ProtectedRoute.tsx:10-27)
- Automatic redirect to login when unauthenticated
- Return to requested page after login
- Loading state during authentication check
User Logout
Logout Methods
Manual Logout:- Click logout button in the application
- Calls backend logout endpoint
- Clears session storage
- 15 minutes of inactivity
- Browser close (sessionStorage cleared)
- Session expiration
Logout Implementation
(src/services/authService.ts:169-182)
Idle Timeout Handler
The system automatically logs out inactive users. Monitored Events: (src/components/auth/IdleHandler.tsx:29)
mousedown- Mouse clickskeydown- Keyboard inputscroll- Page scrollingclick- Element clickstouchstart- Touch interactions
User Roles
Available Roles
Currently, the system supports:ADMIN
Full system access with all permissionsCapabilities:
- Manage students
- Manage instructors
- Manage horses
- Schedule classes
- View reports
- Export data
All registered users are assigned the ADMIN role (
src/pages/Register.tsx:119).
Future versions may include additional roles like Instructor, Viewer, etc.User Profile Management
User Data Structure
(src/services/authService.ts:5-18)
Update User Profile
API Endpoint:PUT /auth/update
Implementation: (src/services/authService.ts:145-166)
Security Best Practices
Password Security
Password Security
Requirements:
- Minimum 8 characters
- Encourage strong passwords with strength meter
- Passwords never logged or displayed
- Use password managers
- Enable auto-fill for convenience
- Regular password rotation
Session Security
Session Security
Protection Measures:
- SessionStorage (cleared on browser close)
- 15-minute idle timeout
- No sensitive data in localStorage
- HTTPS required in production
- Activity tracking via event listeners
- Automatic cleanup on logout
Email Whitelist
Email Whitelist
Purpose:
- Restrict registration to authorized users
- Prevent unauthorized access
- Control user base
- Backend-controlled whitelist
- Real-time validation during registration
- Contact admin to add emails
API Endpoints Reference
Authentication Endpoints
LoginTroubleshooting
Unable to register
Unable to register
Possible causes:
- Email not in whitelist
- Password too weak (< 8 characters)
- Username already taken
- Passwords don’t match
- Verify email is whitelisted
- Use stronger password
- Choose different username
- Check password confirmation
Login failed
Login failed
Possible causes:
- Incorrect username or password
- Account deactivated
- Backend API unavailable
- Verify credentials
- Contact administrator
- Check API connectivity
Session expired
Session expired
Causes:
- 15 minutes of inactivity
- Browser closed
- Manual logout
- Simply log in again
- Stay active to prevent timeout
Next Steps
Data Backup
Configure backup and recovery procedures
Troubleshooting
Common issues and solutions