REST API Usage Examples:
- Register a new user: POST /users/register
{
"username": "johndoe",
"email": "john@example.com",
"password": "secure_password123",
"first_name": "John",
"last_name": "Doe",
"bio": "Software developer",
"timezone": "America/New_York",
"locale": "en-US"
}
- Login: POST /users/login
{
"email": "john@example.com",
"password": "secure_password123"
}
-
Get user: GET /users/{user_id}
-
Update user profile: PUT /users/{user_id}
{
"username": "johnsmith",
"first_name": "John",
"last_name": "Smith",
"bio": "Senior Software Developer"
}
-
Activate user: POST /users/{user_id}/activate
-
Verify user: POST /users/{user_id}/verify
CLI Usage Examples:
-
Register user: ./paladin user register -u johndoe -e john@example.com -p secure_password123 --first-name John --last-name Doe
-
Login: ./paladin user login -e john@example.com -p secure_password123
-
Get user: ./paladin user get -i john@example.com ./paladin user get -i 550e8400-e29b-41d4-a716-446655440000
-
Update user: ./paladin user update -u 550e8400-e29b-41d4-a716-446655440000 --username johnsmith --first-name John
-
List active users: ./paladin user list --active true --limit 20
-
Activate user: ./paladin user activate -u 550e8400-e29b-41d4-a716-446655440000
-
Verify user: ./paladin user verify -u 550e8400-e29b-41d4-a716-446655440000 */
// ============================================================================= // INTEGRATION NOTES // =============================================================================
/* Integration Checklist:
- ✅ Domain Layer - User entity built on Node with Email value object
- ✅ Application Layer - UserService with business logic
- ✅ Infrastructure Layer - SQLite repository implementation
- ✅ Presentation Layer - REST API endpoints
- ✅ CLI Commands - Command-line interface
- ✅ Integration - Service factory and dependency injection
- ✅ Testing - Unit and integration tests
- ✅ Error Handling - Comprehensive UserError types
- ✅ Security - Argon2 password hashing
- ✅ Logging - Integration with LogPort
- ✅ Notifications - Welcome email via existing NotificationPublisherService
Files to create/update:
- src/core/platform/container/user.rs (new)
- src/application/services/user_service.rs (new)
- src/application/ports/output/user_repository_port.rs (new)
- src/infrastructure/repositories/sqlite_user_repository.rs (new)
- src/infrastructure/web/user_controller.rs (new)
- src/application/cli/commands/user.rs (new)
- src/config/user_config.rs (new)
- Update src/config/setup/service_runner.rs
- Update Cargo.toml with dependencies
Integration with Existing Services:
- ✅ Uses existing NotificationPublisherService from notification_port.rs
- ✅ Uses existing LogPort for logging
- ✅ Uses existing Settings struct for configuration
- ✅ Uses existing Node infrastructure for versioning
- ✅ Uses existing Message system for event publishing
Database Migration: The SQLite repository automatically creates the users table with proper indexes. The table schema includes all necessary fields and follows the Node pattern.
Security Features:
- Argon2 password hashing with salt
- Email validation with comprehensive regex
- Username validation rules
- Input sanitization and validation
- Proper error handling without information leakage
Versioning Support: The User type is built on Node, automatically inheriting versioning capabilities. All user changes can be tracked through the existing versioning system.
Integration Points:
- LogPort for user action logging (existing)
- NotificationPublisherService for welcome emails (existing)
- Settings struct for database configuration (existing)
- Existing Node infrastructure for versioning (existing)
- Message system for event publishing (existing)
This implementation provides a complete, production-ready user management system that seamlessly integrates with your existing paladin framework architecture. */_123").is_ok()); assert!(user_service.validate_username("test-user").is_ok());
// Invalid usernames
assert!(user_service.validate_username("").is_err());
assert!(user_service.validate_username("ab").is_err());
assert!(user_service.validate_username("user