feat: Update endpoint signup
This commit is contained in:
parent
4449576506
commit
ab3e1a9c7a
@ -1,33 +1,50 @@
|
||||
from fastapi import APIRouter, HTTPException
|
||||
from fastapi import APIRouter, Depends, HTTPException
|
||||
from core.database import fake_users_db
|
||||
import uuid
|
||||
from typing import Optional
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@router.post("/signup")
|
||||
async def signup_demo(
|
||||
username: str = "new_user",
|
||||
email: str = "user@example.com",
|
||||
password: str = "securepassword123"
|
||||
@router.post("/register")
|
||||
async def register_user(
|
||||
username: str,
|
||||
email: str,
|
||||
password: str,
|
||||
full_name: Optional[str] = None
|
||||
):
|
||||
"""Demo signup endpoint"""
|
||||
"""Register new user endpoint"""
|
||||
if username in fake_users_db:
|
||||
raise HTTPException(status_code=400, detail="Username already exists")
|
||||
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,
|
||||
"disabled": False
|
||||
"full_name": full_name,
|
||||
"disabled": False,
|
||||
"created_at": str(uuid.uuid1())
|
||||
}
|
||||
|
||||
return {
|
||||
"message": "User created successfully",
|
||||
"user_id": user_id,
|
||||
"username": username,
|
||||
"message": "User registered successfully",
|
||||
"user": {
|
||||
"id": user_id,
|
||||
"username": username,
|
||||
"email": email,
|
||||
"full_name": full_name
|
||||
},
|
||||
"next_steps": [
|
||||
"Verify your email (demo)",
|
||||
"Complete profile setup"
|
||||
]
|
||||
}
|
||||
"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