Update code in endpoints/api/v1/endpoint.post.py
This commit is contained in:
parent
696691d94e
commit
aecc5dbaee
@ -1,42 +1,49 @@
|
||||
from fastapi import APIRouter, Depends, HTTPException
|
||||
from core.database import fake_users_db
|
||||
from pydantic import BaseModel, EmailStr
|
||||
import uuid
|
||||
from pydantic import BaseModel, EmailStr
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
class UserRegistration(BaseModel):
|
||||
class CookingCommunityRegistration(BaseModel):
|
||||
username: str
|
||||
email: EmailStr
|
||||
password: str
|
||||
full_name: str
|
||||
cooking_experience: str
|
||||
favorite_cuisine: str
|
||||
|
||||
@router.post("/api/v1/endpoint")
|
||||
async def register_user(user_data: UserRegistration):
|
||||
"""Register a new user"""
|
||||
if user_data.username in fake_users_db:
|
||||
async def register_cooking_community(
|
||||
registration: CookingCommunityRegistration
|
||||
):
|
||||
"""Register new user for cooking community"""
|
||||
if registration.username in fake_users_db:
|
||||
raise HTTPException(status_code=400, detail="Username already exists")
|
||||
|
||||
user_id = str(uuid.uuid4())
|
||||
fake_users_db[user_data.username] = {
|
||||
fake_users_db[registration.username] = {
|
||||
"id": user_id,
|
||||
"email": user_data.email,
|
||||
"password": user_data.password,
|
||||
"full_name": user_data.full_name,
|
||||
"disabled": False
|
||||
"email": registration.email,
|
||||
"password": registration.password,
|
||||
"cooking_experience": registration.cooking_experience,
|
||||
"favorite_cuisine": registration.favorite_cuisine,
|
||||
"disabled": False,
|
||||
"role": "community_member"
|
||||
}
|
||||
|
||||
return {
|
||||
"message": "User registered successfully",
|
||||
"message": "Successfully registered in cooking community",
|
||||
"user_id": user_id,
|
||||
"username": user_data.username,
|
||||
"metadata": {
|
||||
"account_status": "active",
|
||||
"registration_complete": True
|
||||
},
|
||||
"username": registration.username,
|
||||
"next_steps": [
|
||||
"Verify your email address",
|
||||
"Complete your profile",
|
||||
"Set up two-factor authentication"
|
||||
]
|
||||
"Verify your email",
|
||||
"Complete your cooking profile",
|
||||
"Join cooking discussion groups",
|
||||
"Share your favorite recipe"
|
||||
],
|
||||
"features": {
|
||||
"recipe_sharing": True,
|
||||
"community_chat": True,
|
||||
"cooking_tips_access": True
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user