Update code in endpoints/login.post.py
This commit is contained in:
parent
8569bc9086
commit
604ef3b8b3
@ -1,25 +1,40 @@
|
||||
from fastapi import APIRouter, Depends, HTTPException
|
||||
from core.auth import get_current_user_dummy
|
||||
from core.database import fake_users_db
|
||||
import uuid
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@router.post("/login")
|
||||
async def login_demo(
|
||||
username: str = "demo",
|
||||
password: str = "password"
|
||||
@router.post("/signup")
|
||||
async def signup_handler(
|
||||
username: str,
|
||||
email: str,
|
||||
password: str
|
||||
):
|
||||
"""Demo login endpoint"""
|
||||
user = fake_users_db.get(username)
|
||||
if not user or user["password"] != password:
|
||||
raise HTTPException(status_code=400, detail="Invalid credentials")
|
||||
"""Demo signup endpoint"""
|
||||
if username in fake_users_db:
|
||||
raise HTTPException(status_code=400, detail="Username already exists")
|
||||
|
||||
if not username or not email or not password:
|
||||
raise HTTPException(status_code=400, detail="All fields are required")
|
||||
|
||||
user_id = str(uuid.uuid4())
|
||||
fake_users_db[username] = {
|
||||
"id": user_id,
|
||||
"email": email,
|
||||
"password": password,
|
||||
"disabled": False
|
||||
}
|
||||
|
||||
return {
|
||||
"message": "Login successful (demo)",
|
||||
"user": username,
|
||||
"token": "dummy_jwt_token_123",
|
||||
"features": {
|
||||
"rate_limit": 100,
|
||||
"expires_in": 3600
|
||||
"message": "User created successfully",
|
||||
"user_id": user_id,
|
||||
"username": username,
|
||||
"next_steps": [
|
||||
"Verify your email (demo)",
|
||||
"Complete profile setup"
|
||||
],
|
||||
"metadata": {
|
||||
"account_status": "pending_verification",
|
||||
"created_at": "2024-01-01T00:00:00Z"
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user