Update code in endpoints/api/v1/endpoint.post.py

This commit is contained in:
Backend IM Bot 2025-03-18 15:39:42 +00:00
parent 93e54c88aa
commit f4682f1550

View File

@ -0,0 +1,46 @@
from fastapi import APIRouter, Depends, HTTPException
from core.database import fake_users_db
from pydantic import BaseModel, EmailStr
import uuid
router = APIRouter()
class RegistrationData(BaseModel):
username: str
email: EmailStr
password: str
full_name: str
@router.post("/register")
async def register_user(data: RegistrationData):
"""Register new user endpoint"""
if data.username in fake_users_db:
raise HTTPException(status_code=400, detail="Username already exists")
if any(user["email"] == data.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[data.username] = {
"id": user_id,
"email": data.email,
"password": data.password,
"full_name": data.full_name,
"disabled": False,
"created_at": str(uuid.uuid1())
}
return {
"message": "Registration successful",
"user_id": user_id,
"username": data.username,
"next_steps": [
"Verify your email address",
"Complete your profile",
"Set up two-factor authentication"
],
"features": {
"rate_limit": 50,
"expires_in": 3600
}
}