User Account Structure
Users are stored in theusers table with the following schema (database.py:43-51):
Viewing All Users
Administrators can view the complete user directory with:Auto-incremented unique user ID (internal database key)
Student ID number - must be unique, used for card-scan authentication
Full user name
Email address (case-insensitive, stored in lowercase)
Account status:
1 (active) or 0 (inactive). Inactive users cannot log in.Account creation timestamp
User Registration
New users can self-register through the/register route (mainwebsite.py:152-164).
Managing User Active Status
Theactive field controls whether a user can access the system.
Active Users (active = 1)
- Can authenticate with student ID card or email/password
- Can check out and return books
- Full access to catalog and personal borrowing history
Inactive Users (active = 0)
- Cannot log in - authentication fails even with valid credentials (database.py:209)
- Existing checkouts remain in system
- Can be reactivated by admin
Authentication checks active status:
if user and user['active'] (mainwebsite.py:209)Viewing User Borrowing History
Administrators can view complete borrowing records for any user.Current Checkouts
View active loans for a user:- Book title, author, and cover
- Checkout date
- Due date
- Overdue status (if past due date)
Borrowing History
View all past transactions:- Book details
- Checkout and return dates
- Total borrowing activity
User Loan Records
Theloans table tracks all checkouts (database.py:62-70):
References users(id) - links loan to user account
References books(isbn) - identifies which book was borrowed
Timestamp when book was checked out
Return deadline (14 days from checkout by default)
0 = still checked out, 1 = returnedTimestamp when book was returned (null if still checked out)
Test Accounts
The system includes pre-configured test accounts (mock_data.py:43-47):To create test accounts, run:
python mock_data.py (mock_data.py:51-127)User Authentication Methods
The system supports two authentication methods:Student ID Card Scan
For kiosk usage (mainwebsite.py:224-258):- Scans student ID barcode
- Looks up user by
student_idfield (database.py:120-130) - Automatically logs in if active
Email/Password Login
For web access and admin users (mainwebsite.py:204-221):- Validates email and password
- Uses bcrypt for secure password verification (database.py:112)
- Returns user data if credentials match and account is active
Managing User Access
Activating a User
To enable access for an inactive user:Deactivating a User
To suspend access without deleting the account:User Activity Monitoring
Administrators should monitor:Overdue Books
Identify users with overdue items (mainwebsite.py:330-337):Checkout Patterns
Track user borrowing behavior:- Total checkouts per user
- Most active borrowers
- Renewal patterns
The SRS (US009, lines 234-243) specifies future features including:
- Setting borrowing limits per user
- Semester reset functionality
- Enhanced user reporting
User Data Privacy
Security measures in place:- Password hashing - bcrypt with automatic salt generation (database.py:80)
- Case-insensitive email - prevents duplicate accounts (database.py:47)
- No sensitive PII storage - minimal personal data retained
- SQL injection protection - parameterized queries throughout (database.py)
Common Administrative Tasks
Finding a User by Email
Finding a User by Student ID
Viewing a User’s Current Checkouts
Checking User Active Status
The returned user dict includes theactive boolean:
Database Reference
Key functions for user management:register_user(name, email, student_id, password)- Create new account (database.py:77-98)authenticate_user(email, password)- Validate login credentials (database.py:101-117)get_user_by_id(student_id)- Look up user by student ID (database.py:120-130)get_user_loans(user_id)- Fetch all loans for a user (database.py:332-360)
Next Steps
Reports
Generate user activity reports and statistics
Book Management
Manage the library catalog