User Managementο
This guide covers managing users in PutPlace using the pp_manage_users command-line tool.
Overviewο
PutPlace uses MongoDB to store user accounts. Users can be:
Active users - Can log in and use the system
Pending users - Registered but awaiting email confirmation
Admin users - Have administrative privileges
Installationο
The pp_manage_users command is installed as part of the putplace-server package:
# Run directly
pp_manage_users --help
# Or via uv
uv run pp_manage_users --help
Quick Referenceο
Command |
Description |
|---|---|
|
List all active users |
|
List users awaiting email confirmation |
|
Create a new user |
|
Approve a pending user |
|
Delete a user |
|
Reset a userβs password |
|
Grant admin privileges |
|
Revoke admin privileges |
Commandsο
List Usersο
List all active users in the database:
# Rich table output (default)
pp_manage_users list
# Plain text output (for scripting)
pp_manage_users list --no-table
Example output:
βββββββββββββββββββββββββ³βββββββββββββββ³ββββββββ³βββββββββ³βββββββββββββββββββ
β Email β Name β Admin β Active β Created β
β‘βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ©
β admin@example.com β Administratorβ Yes β Yes β 2024-01-15 10:30 β
β user@example.com β John Doe β No β Yes β 2024-01-16 14:22 β
βββββββββββββββββββββββββ΄βββββββββββββββ΄ββββββββ΄βββββββββ΄βββββββββββββββββββ
List Pending Usersο
Show users who have registered but not yet confirmed their email:
pp_manage_users pending
Pending users have an expiration time. Expired registrations can be cleaned up or manually approved.
Add a New Userο
Create a user directly (bypassing email confirmation):
# Interactive mode (prompts for all values)
pp_manage_users add
# With command-line arguments
pp_manage_users add --email user@example.com --password secret123
# With full name
pp_manage_users add --email user@example.com --password secret123 --name "John Doe"
# Create an admin user
pp_manage_users add --email admin@example.com --password secret123 --admin
Password requirements:
Minimum 8 characters
Approve Pending Usersο
Approve a user who registered but hasnβt confirmed their email:
# Interactive mode (shows available pending users)
pp_manage_users approve
# Approve specific user
pp_manage_users approve --email user@example.com
# Approve and grant admin privileges
pp_manage_users approve --email user@example.com --admin
This moves the user from the pending_users collection to the users collection.
Delete a Userο
Remove a user from the system:
# Interactive mode (shows users and confirms)
pp_manage_users delete
# Delete specific user
pp_manage_users delete --email user@example.com
# Skip confirmation prompt
pp_manage_users delete --email user@example.com --force
Reset Passwordο
Change a userβs password:
# Interactive mode (prompts for new password)
pp_manage_users reset-password
# With command-line arguments
pp_manage_users reset-password --email user@example.com --password newpass123
Manage Admin Privilegesο
Grant admin privileges:
pp_manage_users setadmin --email user@example.com
Revoke admin privileges:
pp_manage_users unsetadmin --email admin@example.com
Global Optionsο
These options apply to all commands:
# Use a custom MongoDB URL
pp_manage_users --mongodb-url mongodb://host:27017 list
# Use a different database
pp_manage_users --database putplace_prod list
# Combine options
pp_manage_users --mongodb-url mongodb://prod-host:27017 --database putplace_prod list
Default values:
--mongodb-url:mongodb://localhost:27017--database:putplace
User Lifecycleο
βββββββββββββββββββ
β Registration β
β (via API) β
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββ βββββββββββββββββββ
β Pending User ββββββΆβ Email Sent β
β (pending_users)β β (confirmation) β
ββββββββββ¬βββββββββ βββββββββββββββββββ
β
β Email confirmed OR
β pp_manage_users approve
βΌ
βββββββββββββββββββ
β Active User β
β (users) β
ββββββββββ¬βββββββββ
β
β pp_manage_users setadmin
βΌ
βββββββββββββββββββ
β Admin User β
β (is_admin=true)β
βββββββββββββββββββ
Database Collectionsο
PutPlace stores users in two MongoDB collections:
users Collectionο
Active, confirmed users:
{
"_id": "ObjectId",
"email": "user@example.com",
"username": "user@example.com",
"hashed_password": "bcrypt hash",
"full_name": "John Doe",
"is_active": true,
"is_admin": false,
"created_at": "2024-01-15T10:30:00Z"
}
pending_users Collectionο
Users awaiting email confirmation:
{
"_id": "ObjectId",
"email": "newuser@example.com",
"hashed_password": "bcrypt hash",
"full_name": "Jane Smith",
"confirmation_token": "random-token",
"created_at": "2024-01-16T14:00:00Z",
"expires_at": "2024-01-17T14:00:00Z"
}
Scripting Examplesο
Backup user listο
pp_manage_users list --no-table > users_backup.txt
Check if user existsο
if pp_manage_users list --no-table | grep -q "user@example.com"; then
echo "User exists"
fi
Bulk user creationο
#!/bin/bash
while IFS=, read -r email name password; do
pp_manage_users add --email "$email" --name "$name" --password "$password"
done < users.csv
Troubleshootingο
Cannot connect to MongoDBο
β Could not connect to MongoDB: ...
Check that:
MongoDB is running:
invoke mongo-statusThe connection URL is correct
Network connectivity to the MongoDB host
User already existsο
β User with email 'user@example.com' already exists.
The email is already registered. Use reset-password to change credentials or delete to remove.
Password too shortο
β Password must be at least 8 characters long.
Provide a password with at least 8 characters.
See Alsoο
Authentication - Authentication system overview
Configuration - Server configuration
API Reference - REST API endpoints for user management