Overview
TheUser model represents system users with authentication, role-based access control, and personal information. Users can have different roles (admin, assistant, or artist) and optionally be linked to an Artist record.
Model Definition
Fields
Primary Key
Unique identifier for the user
Authentication
Unique username for loginConstraints: Unique, indexedLength: Maximum 64 characters
Hashed password (never store plain text passwords)Length: Maximum 255 characters to accommodate various hashing algorithms
Authorization
User’s role in the systemValid Values: “admin”, “assistant”, “artist”Indexed: Yes, for role-based queries
Foreign key reference to artists table (only used when role == “artist”)Foreign Key: artists.idNullable: True (only set for artist users)
Whether the user account is activeUsage: Allows disabling accounts without deletion
Personal Information
User’s full name (not the same as artist name)
User’s date of birth
User’s email addressIndexed: YesNote: Can have unique constraint (conditional unique index)
Contact phone number
Instagram handle (stored without ”@” prefix)Indexed: Yes
Metadata
Timestamp when the user account was createdAuto-generated: Yes (server default)
Timestamp of the user’s last loginNullable: True
Database Schema
User Roles
Admin
- Full system access
- Can manage all users, artists, clients, and settings
- No
artist_idassociation
Assistant
- Can manage clients and sessions
- Limited access to financial reports
- No
artist_idassociation
Artist
- Can view and manage their own sessions
- Can view their own portfolio and reports
- Must have
artist_idlinking to an Artist record
Usage Examples
Create a New User
Authenticate User
Query Users by Role
Update User Information
Deactivate User
Security Considerations
- Never store plain text passwords - always use
password_hash - Use strong hashing algorithms (bcrypt, argon2, scrypt)
- The
is_activeflag provides soft deletion for security audits last_loginhelps track account activity- Username must be unique across the system
- Artist users must have a valid
artist_id
Notes
- The
usernamefield is the primary authentication credential nameis the user’s real name, separate from artist stage names- Instagram handles are stored without the ”@” prefix
- Email can have a conditional unique index (implementation dependent)
artist_idcreates a link between user authentication and artist business logic- The
rolefield determines permissions and access levels - Location in codebase:
data/models/user.py:4