Overview
The User model represents user accounts in the Checawaa system. User data is stored indata/usuarios.json as a JSON array.
Schema
Unique identifier for the user. Used for login authentication and attendance tracking.Constraints: Must be unique across all usersExamples:
"admin", "empleado1"User password stored in plain text.Example:
"123"User’s email address. Used for sending automated reminder notifications.Format: Valid email addressExamples:
"[email protected]", "[email protected]"JSON Structure
Complete Example
The defaultdata/usuarios.json file:
Implementation Details
User data initialization (app.py:30-35):User Roles
The system distinguishes users by their username:Username:
adminPrivileges:- Access to
/monitordashboard - Can view all attendance records
- Can see absent users
- Excluded from reminder emails
- Redirected to monitor page after login
Any username except “admin”Privileges:
- Access to home page (
/) - Can submit location via
/update-location - Cannot access
/monitor(redirected to home) - Receive reminder emails if not checked in
- Redirected to home page after login
Authentication Flow
- User submits username and password via
/loginendpoint - System reads all users from
data/usuarios.json - Checks if any user matches both username and password
- If match found, creates session with Flask-Login
- User ID stored in session is the username string
Flask-Login Integration
The User class for session management (app.py:45-46):current_user.id in authenticated requests contains the username string.
Email Notifications
Users receive automated emails at 8:00 AM if they haven’t checked in for the day. The system:- Loads all users from
usuarios.json - Excludes users with username “admin”
- Checks today’s attendance records
- Sends reminder to
emailfield of users not found in today’s records
Security Considerations
For production use, implement:- Password hashing (bcrypt, argon2)
- Secure secret key management
- Environment variables for credentials
- HTTPS/TLS encryption
- Login attempt throttling