Update code in endpoints/api/v1/endpoint.post.py
This commit is contained in:
parent
de91512387
commit
4449576506
50
endpoints/api/v1/endpoint.post.py
Normal file
50
endpoints/api/v1/endpoint.post.py
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user