From 67018d31e1cf6ef25806471624d98b8293af8298 Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Tue, 18 Mar 2025 13:40:50 +0000 Subject: [PATCH] feat: Update endpoint login --- endpoints/login.post.py | 52 ++++++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/endpoints/login.post.py b/endpoints/login.post.py index df5aa08..d37a5ca 100644 --- a/endpoints/login.post.py +++ b/endpoints/login.post.py @@ -1,25 +1,45 @@ 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") + """Create new user account""" + if username in fake_users_db: + raise HTTPException(status_code=400, detail="Username already exists") + + 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 { - "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 address", + "Complete your profile", + "Set up two-factor authentication" + ], + "metadata": { + "account_status": "pending_verification", + "created_timestamp": fake_users_db[username]["created_at"] } - } + } \ No newline at end of file