feat: Update endpoint login
This commit is contained in:
parent
94448f1db1
commit
67018d31e1
@ -1,25 +1,45 @@
|
|||||||
from fastapi import APIRouter, Depends, HTTPException
|
from fastapi import APIRouter, Depends, HTTPException
|
||||||
from core.auth import get_current_user_dummy
|
|
||||||
from core.database import fake_users_db
|
from core.database import fake_users_db
|
||||||
|
import uuid
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
@router.post("/login")
|
@router.post("/signup")
|
||||||
async def login_demo(
|
async def signup_handler(
|
||||||
username: str = "demo",
|
username: str,
|
||||||
password: str = "password"
|
email: str,
|
||||||
|
password: str
|
||||||
):
|
):
|
||||||
"""Demo login endpoint"""
|
"""Create new user account"""
|
||||||
user = fake_users_db.get(username)
|
if username in fake_users_db:
|
||||||
if not user or user["password"] != password:
|
raise HTTPException(status_code=400, detail="Username already exists")
|
||||||
raise HTTPException(status_code=400, detail="Invalid credentials")
|
|
||||||
|
if not email or '@' not in email:
|
||||||
|
raise HTTPException(status_code=400, detail="Invalid email format")
|
||||||
|
|
||||||
|
if len(password) < 8:
|
||||||
|
raise HTTPException(status_code=400, detail="Password must be at least 8 characters")
|
||||||
|
|
||||||
|
user_id = str(uuid.uuid4())
|
||||||
|
fake_users_db[username] = {
|
||||||
|
"id": user_id,
|
||||||
|
"email": email,
|
||||||
|
"password": password,
|
||||||
|
"disabled": False,
|
||||||
|
"created_at": str(uuid.uuid1())
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"message": "Login successful (demo)",
|
"message": "User created successfully",
|
||||||
"user": username,
|
"user_id": user_id,
|
||||||
"token": "dummy_jwt_token_123",
|
"username": username,
|
||||||
"features": {
|
"next_steps": [
|
||||||
"rate_limit": 100,
|
"Verify your email address",
|
||||||
"expires_in": 3600
|
"Complete your profile",
|
||||||
|
"Set up two-factor authentication"
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"account_status": "pending_verification",
|
||||||
|
"created_timestamp": fake_users_db[username]["created_at"]
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user