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 fastapi import APIRouter, Depends, HTTPException
|
||||||
from core.database import fake_users_db
|
from core.database import fake_users_db
|
||||||
from pydantic import BaseModel, EmailStr
|
|
||||||
import uuid
|
import uuid
|
||||||
|
from pydantic import BaseModel, EmailStr
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
class UserRegistration(BaseModel):
|
class CookingCommunityRegistration(BaseModel):
|
||||||
username: str
|
username: str
|
||||||
email: EmailStr
|
email: EmailStr
|
||||||
password: str
|
password: str
|
||||||
full_name: str
|
cooking_experience: str
|
||||||
|
favorite_cuisine: str
|
||||||
|
|
||||||
@router.post("/api/v1/endpoint")
|
@router.post("/api/v1/endpoint")
|
||||||
async def register_user(user_data: UserRegistration):
|
async def register_cooking_community(
|
||||||
"""Register a new user"""
|
registration: CookingCommunityRegistration
|
||||||
if user_data.username in fake_users_db:
|
):
|
||||||
|
"""Register new user for cooking community"""
|
||||||
|
if registration.username in fake_users_db:
|
||||||
raise HTTPException(status_code=400, detail="Username already exists")
|
raise HTTPException(status_code=400, detail="Username already exists")
|
||||||
|
|
||||||
user_id = str(uuid.uuid4())
|
user_id = str(uuid.uuid4())
|
||||||
fake_users_db[user_data.username] = {
|
fake_users_db[registration.username] = {
|
||||||
"id": user_id,
|
"id": user_id,
|
||||||
"email": user_data.email,
|
"email": registration.email,
|
||||||
"password": user_data.password,
|
"password": registration.password,
|
||||||
"full_name": user_data.full_name,
|
"cooking_experience": registration.cooking_experience,
|
||||||
"disabled": False
|
"favorite_cuisine": registration.favorite_cuisine,
|
||||||
|
"disabled": False,
|
||||||
|
"role": "community_member"
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"message": "User registered successfully",
|
"message": "Successfully registered in cooking community",
|
||||||
"user_id": user_id,
|
"user_id": user_id,
|
||||||
"username": user_data.username,
|
"username": registration.username,
|
||||||
"metadata": {
|
|
||||||
"account_status": "active",
|
|
||||||
"registration_complete": True
|
|
||||||
},
|
|
||||||
"next_steps": [
|
"next_steps": [
|
||||||
"Verify your email address",
|
"Verify your email",
|
||||||
"Complete your profile",
|
"Complete your cooking profile",
|
||||||
"Set up two-factor authentication"
|
"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