50 lines
1.3 KiB
Python
50 lines
1.3 KiB
Python
from fastapi import APIRouter, Depends, HTTPException
|
|
from core.database import fake_users_db
|
|
import uuid
|
|
from typing import Optional
|
|
|
|
router = APIRouter()
|
|
|
|
@router.post("/register")
|
|
async def register_user(
|
|
username: str,
|
|
email: str,
|
|
password: str,
|
|
full_name: Optional[str] = None
|
|
):
|
|
"""Register new user endpoint"""
|
|
if username in fake_users_db:
|
|
raise HTTPException(status_code=400, detail="Username already registered")
|
|
|
|
if any(user["email"] == email for user in fake_users_db.values()):
|
|
raise HTTPException(status_code=400, detail="Email already registered")
|
|
|
|
user_id = str(uuid.uuid4())
|
|
fake_users_db[username] = {
|
|
"id": user_id,
|
|
"username": username,
|
|
"email": email,
|
|
"password": password,
|
|
"full_name": full_name,
|
|
"disabled": False,
|
|
"created_at": str(uuid.uuid1())
|
|
}
|
|
|
|
return {
|
|
"message": "User registered successfully",
|
|
"user": {
|
|
"id": user_id,
|
|
"username": username,
|
|
"email": email,
|
|
"full_name": full_name
|
|
},
|
|
"next_steps": [
|
|
"Verify your email address",
|
|
"Complete your profile",
|
|
"Set up two-factor authentication"
|
|
],
|
|
"features": {
|
|
"rate_limit": 100,
|
|
"trial_period_days": 30
|
|
}
|
|
} |