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
|
from core.database import fake_users_db
|
||||||
import uuid
|
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
@router.post("/signup")
|
@router.post("/login")
|
||||||
async def signup_demo(
|
async def login_handler(
|
||||||
username: str = "new_user",
|
username: str = "demo",
|
||||||
email: str = "user@example.com",
|
password: str = "password"
|
||||||
password: str = "securepassword123"
|
|
||||||
):
|
):
|
||||||
"""Demo signup endpoint"""
|
"""Demo login endpoint"""
|
||||||
if username in fake_users_db:
|
user = fake_users_db.get(username)
|
||||||
raise HTTPException(status_code=400, detail="Username already exists")
|
if not user or user["password"] != password:
|
||||||
|
raise HTTPException(status_code=400, detail="Invalid credentials")
|
||||||
user_id = str(uuid.uuid4())
|
|
||||||
fake_users_db[username] = {
|
|
||||||
"id": user_id,
|
|
||||||
"email": email,
|
|
||||||
"password": password,
|
|
||||||
"disabled": False
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"message": "User created successfully",
|
"message": "Login successful",
|
||||||
"user_id": user_id,
|
"user": username,
|
||||||
"username": username,
|
"token": "dummy_jwt_token_123",
|
||||||
"next_steps": [
|
"features": {
|
||||||
"Verify your email (demo)",
|
"rate_limit": 100,
|
||||||
"Complete profile setup"
|
"expires_in": 3600
|
||||||
]
|
},
|
||||||
}
|
"metadata": {
|
||||||
|
"login_time": "2024-01-01T00:00:00Z",
|
||||||
|
"session_type": "demo"
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user