Overview
DADDO uses a secure token-based authentication system built with JWT tokens. The authentication flow includes user registration, login with remember me functionality, password recovery, and protected routes.Login Flow
Redux Action: LoginUser
The login system is implemented insrc/Redux/actions/Auth/login.js and handles authentication with token storage:
The
rememberMe parameter determines whether credentials are stored in localStorage (persistent) or sessionStorage (session-only).Login Component
The login page (src/Views/LoginPage.jsx) provides a modern UI with:
- Email and password input fields
- Password visibility toggle
- “Remember me” checkbox
- Error message display
- Loading states
- Links to registration and public catalogs
- Real-time form validation
- Animated UI with fade-in effects
- Responsive design with gradient backgrounds
- Auto-navigation on successful login
User Registration
Create User Action
New users are registered through thecreateUser action in src/Redux/actions/Auth/create_user.js:
Registration Page
Access the registration form at
/create to create a new account with business details.User Profile
After registration, users can update their profile information including business name and phone.
Password Recovery
Request Password Reset
The password recovery system uses a two-step verification process: Step 1: Request Reset Email Implemented insrc/Redux/actions/Auth/requestPassword.js:
Password Reset Component
TheForgotPassword component (src/components/ForgotPassword.jsx) provides:
- Token validation on page load
- New password input with confirmation
- Password strength requirements (minimum 6 characters)
- Success/error notifications
- Auto-redirect to login after successful reset
Password Reset Flow
Password Reset Flow
- User requests password reset by providing email
- System sends email with unique reset token
- User clicks link in email with token parameter
- Component validates token on load
- If valid, user can enter new password
- System updates password and redirects to login
Protected Routes
Route Protection Component
All authenticated routes are protected using theProtected_Route component (src/components/Protected_Route.jsx):
Protected Routes List
The following routes require authentication (src/App.jsx):
/home
Main dashboard homepage
/createProd
Create new products
/my-catalog
Generate catalog links and QR codes
/createSell
Record new sales
/dash
Analytics dashboard
/Sells
View sales history
/products
Manage all products
/profile
User profile settings
Logout Functionality
Users can logout using the logout action that clears all stored credentials:Security Features
Token Management
Token Management
- JWT tokens stored securely in browser storage
- Automatic token validation on protected routes
- Token included in API request headers
- Session vs. persistent storage based on user preference
Error Handling
Error Handling
- User-friendly error messages
- Automatic redirect on invalid/expired tokens
- Storage cleanup on authentication failures
- Toast notifications for all auth events
User Experience
User Experience
- Loading states during authentication
- Animated transitions
- Password visibility toggle
- Auto-navigation on success
- Remember me functionality
API Integration
All authentication requests use the centralized API instance configured insrc/Redux/api.js with:
- Base URL configuration
- Automatic token injection in headers
- Error interceptors
- Response transformers
The authentication system automatically handles token refresh and maintains user session across page reloads when “Remember me” is enabled.