41 lines
967 B
Python
41 lines
967 B
Python
from fastapi import APIRouter, HTTPException
|
|
import uuid
|
|
|
|
# In-memory storage
|
|
users = []
|
|
posts = []
|
|
|
|
router = APIRouter()
|
|
|
|
@router.post("/signup")
|
|
async def signup_user(
|
|
username: str,
|
|
email: str,
|
|
password: str
|
|
):
|
|
"""Create new user account"""
|
|
if any(u["username"] == username for u in users):
|
|
raise HTTPException(status_code=400, detail="Username already exists")
|
|
|
|
if any(u["email"] == email for u in users):
|
|
raise HTTPException(status_code=400, detail="Email already registered")
|
|
|
|
user_id = str(uuid.uuid4())
|
|
user = {
|
|
"id": user_id,
|
|
"username": username,
|
|
"email": email,
|
|
"password": password,
|
|
"disabled": False
|
|
}
|
|
users.append(user)
|
|
|
|
return {
|
|
"message": "User created successfully",
|
|
"user_id": user_id,
|
|
"username": username,
|
|
"next_steps": [
|
|
"Verify your email",
|
|
"Complete profile setup"
|
|
]
|
|
} |