Update code in endpoints/signup.post.py
This commit is contained in:
parent
3de96679c6
commit
5b88e1ea17
@ -1,33 +1,28 @@
|
||||
from fastapi import APIRouter, HTTPException
|
||||
from fastapi import APIRouter, Depends, HTTPException
|
||||
from core.database import fake_users_db
|
||||
import uuid
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@router.post("/signup")
|
||||
async def signup_demo(
|
||||
username: str = "new_user",
|
||||
email: str = "user@example.com",
|
||||
password: str = "securepassword123"
|
||||
@router.post("/login")
|
||||
async def login_handler(
|
||||
username: str = "demo",
|
||||
password: str = "password"
|
||||
):
|
||||
"""Demo signup endpoint"""
|
||||
if username in fake_users_db:
|
||||
raise HTTPException(status_code=400, detail="Username already exists")
|
||||
|
||||
user_id = str(uuid.uuid4())
|
||||
fake_users_db[username] = {
|
||||
"id": user_id,
|
||||
"email": email,
|
||||
"password": password,
|
||||
"disabled": False
|
||||
}
|
||||
"""Demo login endpoint"""
|
||||
user = fake_users_db.get(username)
|
||||
if not user or user["password"] != password:
|
||||
raise HTTPException(status_code=400, detail="Invalid credentials")
|
||||
|
||||
return {
|
||||
"message": "User created successfully",
|
||||
"user_id": user_id,
|
||||
"username": username,
|
||||
"next_steps": [
|
||||
"Verify your email (demo)",
|
||||
"Complete profile setup"
|
||||
]
|
||||
}
|
||||
"message": "Login successful",
|
||||
"user": username,
|
||||
"token": "dummy_jwt_token_123",
|
||||
"features": {
|
||||
"rate_limit": 100,
|
||||
"expires_in": 3600
|
||||
},
|
||||
"metadata": {
|
||||
"login_time": "2024-01-01T00:00:00Z",
|
||||
"session_type": "demo"
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user