User Management
Relevant source files
The following files were used as context for generating this wiki page:
Introduction
User Management in the Fikak application encompasses the processes of authentication, session handling, and profile maintenance. It serves as the foundational layer for personalized user experiences, ensuring that user data is securely handled and accessible throughout the application lifecycle.
The system integrates with Firebase for authentication and utilizes a provider-based state management pattern to synchronize user data across different UI components. This ensures that changes to a user's profile or authentication status are reflected in real-time across the app.
Sources: lib/services/auth_service.dart, lib/providers/user_provider.dart
Authentication Flow
The authentication system supports standard email and password login, as well as account creation. The AuthService class acts as the primary interface for interacting with the authentication backend.
Login and Registration Logic
The application utilizes a repository pattern to abstract the complexity of Firebase Authentication. When a user attempts to log in, the input credentials are validated and passed to the service layer.
The flow ensures that only authenticated users can access protected routes. If authentication fails, the AuthService returns specialized error codes which are then displayed to the user on the login screen.
Sources: lib/services/auth_service.dart:15-45, lib/screens/login_screen.dart:50-80
User Data Model
The user profile is represented by a structured data model that mirrors the information stored in the backend database. This model includes basic identity information and application-specific settings.
| Field | Type | Description |
|---|---|---|
| uid | String | Unique identifier from Firebase Auth |
| String | User's registered email address | |
| displayName | String | Name displayed in the app UI |
| photoUrl | String | URL to the user's profile image |
| createdAt | DateTime | Timestamp of account creation |
Sources: lib/models/user_model.dart:5-25
State Management via UserProvider
The UserProvider class manages the global state of the currently logged-in user. It uses the ChangeNotifier mixin to alert the UI whenever user data is updated.
State Synchronization Flow
The following sequence diagram illustrates how the UserProvider updates the UI after a successful profile modification.
This reactive approach ensures that the ProfileScreen and any other active widgets stay in sync without manual refreshes.
Sources: lib/providers/user_provider.dart:10-40, lib/screens/profile_screen.dart:100-120
Profile Management
Users can view and edit their profile information through the ProfileScreen. This module allows for the modification of display names and profile pictures.
Key Components
- TextEditingControllers: Used to capture user input in the profile forms.
- Image Picker Integration: Allows users to select images from their device gallery to update their
photoUrl. - Validation Logic: Ensures that usernames meet specific length and character requirements before submission.
Sources: lib/screens/profile_screen.dart:20-65
Conclusion
The User Management system is a robust framework combining secure Firebase authentication with flexible state management. By decoupling the authentication logic from the UI and using a centralized provider, the application maintains high performance and data integrity across all user-related interactions.