Overview
Softbee provides a complete authentication system that allows beekeepers to create accounts, manage their credentials, and securely access their apiary data. The authentication system is built with JWT tokens and includes password recovery functionality.Key Features
User Registration
Create new accounts with email verification and apiary setup
Secure Login
Email/username-based authentication with password visibility toggle
Password Recovery
Reset forgotten passwords via email verification
Account Verification
Email verification to ensure account authenticity
User Entity
TheUser entity represents an authenticated beekeeper in the system:
lib/feature/auth/core/entities/user.dart
User Registration Flow
The registration process is designed to collect essential information about the beekeeper and their apiaries in a multi-step workflow.Personal Information
Users provide their full name, email, phone number, and password.Password Requirements:
- Minimum 8 characters
- At least one uppercase letter (A-Z)
- At least one lowercase letter (a-z)
- At least one number (0-9)
- At least one special character (@$!%*?&)
The password strength is validated in real-time with visual indicators showing which requirements are met.
Apiary Information
Users can add one or more apiaries during registration:
- Apiary Name: Unique identifier for the apiary (e.g., “Apiario Las Flores”)
- Exact Address: Full location details (e.g., “Cota, Vereda El Rosal - Finca La Esperanza”)
- Treatment Practices: Whether treatments are applied when bees are sick
lib/feature/auth/presentation/pages/register_page.dart:1-1186
Login Flow
The login page provides a responsive interface for users to authenticate.Authentication Process
Enter Credentials
Users can log in with:
- Email address
- Password
Validation
Client-side validation ensures:
- Email/username is not empty
- Password is at least 8 characters
Authentication
The login request is sent to the backend:
- JWT token is returned on success
- Token is stored locally for subsequent requests
- User data is cached
lib/feature/auth/presentation/pages/login_page.dart:1-780
Responsive Design
The login page adapts to different screen sizes:- Desktop (1024px+): Side-by-side layout with branding panel and login form
- Tablet/Landscape: Two-column layout optimized for horizontal screens
- Mobile (600px and below): Stacked vertical layout with centered content
Password Recovery
Users who forget their password can initiate a recovery process.
Implementation:
lib/feature/auth/presentation/pages/forgot_password_page.dart and reset_password_page.dart
Use Cases
The authentication feature implements several use cases following Clean Architecture principles:| Use Case | Purpose | Location |
|---|---|---|
LoginUseCase | Authenticate user with credentials | lib/feature/auth/core/usecase/login_usecase.dart |
RegisterUseCase | Create new user account | lib/feature/auth/core/usecase/register_usecase.dart |
LogoutUseCase | End user session | lib/feature/auth/core/usecase/logout_usecase.dart |
CheckAuthStatusUseCase | Verify if user is authenticated | lib/feature/auth/core/usecase/check_auth_status_usecase.dart |
GetUserFromTokenUseCase | Retrieve user data from stored token | lib/feature/auth/core/usecase/get_user_from_token_usecase.dart |
UI Components
Loading State
During login and registration operations, a Lottie animation (LoadHIVE.json) is displayed to provide visual feedback.
Error Handling
Errors are displayed in two ways:- Inline Validation: Field-level errors appear below the input with red styling
- Alert Dialogs: Server errors are shown in styled dialogs with icons
Success Confirmation
Successful registration shows a modal dialog with:- Green check icon
- Success message
- “Continue” button that redirects to dashboard
State Management
Authentication state is managed using Riverpod:AuthState tracks:
isAuthenticated: Whether user is logged inuser: Current user dataisLoading: Loading state for async operationserrorMessage: Error messages to display
Security Features
All passwords are hashed before storage and transmitted over HTTPS. JWT tokens expire after a configurable period and must be refreshed.
- Token-based authentication: JWT tokens for stateless auth
- Local storage: Secure token storage on device
- Password hashing: Bcrypt hashing on the backend
- Email verification: Prevents fake account creation
- Session management: Automatic logout on token expiration
Routes
Authentication-related routes defined inapp_routes.dart:
/login- Login page/register- Registration page/forgot-password- Password recovery request/reset-password- Password reset form/dashboard- Post-login landing page
Related Features
Once authenticated, users can access:- Apiaries Management - Manage apiary locations
- Beehives - Track individual hives
- Monitoring - Health and inspection data
- Inventory - Equipment and supply tracking