Update code in endpoints/api/v1/endpoint.post.py
This commit is contained in:
parent
aecc5dbaee
commit
5891d59a13
@ -1,49 +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
|
||||||
import uuid
|
import uuid
|
||||||
from pydantic import BaseModel, EmailStr
|
from pydantic import BaseModel
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
class CookingCommunityRegistration(BaseModel):
|
class CompanyRegistration(BaseModel):
|
||||||
username: str
|
company_name: str
|
||||||
email: EmailStr
|
user_name: str
|
||||||
|
email: str
|
||||||
password: str
|
password: str
|
||||||
cooking_experience: str
|
role: str = "employee"
|
||||||
favorite_cuisine: str
|
|
||||||
|
|
||||||
@router.post("/api/v1/endpoint")
|
@router.post("/register/company")
|
||||||
async def register_cooking_community(
|
async def register_company_user(registration: CompanyRegistration):
|
||||||
registration: CookingCommunityRegistration
|
"""Register a new user in a company"""
|
||||||
):
|
if registration.user_name 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[registration.username] = {
|
company_id = str(uuid.uuid4())
|
||||||
|
|
||||||
|
fake_users_db[registration.user_name] = {
|
||||||
"id": user_id,
|
"id": user_id,
|
||||||
|
"company_id": company_id,
|
||||||
|
"company_name": registration.company_name,
|
||||||
"email": registration.email,
|
"email": registration.email,
|
||||||
"password": registration.password,
|
"password": registration.password,
|
||||||
"cooking_experience": registration.cooking_experience,
|
"role": registration.role,
|
||||||
"favorite_cuisine": registration.favorite_cuisine,
|
"disabled": False
|
||||||
"disabled": False,
|
|
||||||
"role": "community_member"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"message": "Successfully registered in cooking community",
|
"message": "Company user registered successfully",
|
||||||
"user_id": user_id,
|
"user_id": user_id,
|
||||||
"username": registration.username,
|
"company_id": company_id,
|
||||||
|
"username": registration.user_name,
|
||||||
"next_steps": [
|
"next_steps": [
|
||||||
"Verify your email",
|
"Verify company email",
|
||||||
"Complete your cooking profile",
|
"Complete company profile",
|
||||||
"Join cooking discussion groups",
|
"Invite team members"
|
||||||
"Share your favorite recipe"
|
|
||||||
],
|
],
|
||||||
"features": {
|
"features": {
|
||||||
"recipe_sharing": True,
|
"max_team_members": 10,
|
||||||
"community_chat": True,
|
"storage_limit": "5GB",
|
||||||
"cooking_tips_access": True
|
"trial_period_days": 30
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user