From a25cd72d37f98a0e1e1c0f33fa87d0b43ade4d41 Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Wed, 19 Mar 2025 18:16:14 +0000 Subject: [PATCH] Update code in endpoints/login.post.py --- endpoints/login.post.py | 48 ++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/endpoints/login.post.py b/endpoints/login.post.py index df5aa08..b3a3d56 100644 --- a/endpoints/login.post.py +++ b/endpoints/login.post.py @@ -1,25 +1,39 @@ 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("/database") +async def create_database( + name: str = "default_db", + description: str = "Demo database" ): - """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 a new database""" + db_id = str(uuid.uuid4()) + + if name in fake_users_db: + raise HTTPException(status_code=400, detail="Database with this name already exists") + + fake_users_db[name] = { + "id": db_id, + "name": name, + "description": description, + "created_at": "2024-01-01T00:00:00Z", + "status": "active" + } return { - "message": "Login successful (demo)", - "user": username, - "token": "dummy_jwt_token_123", - "features": { - "rate_limit": 100, - "expires_in": 3600 - } - } + "message": "Database created successfully", + "database_id": db_id, + "name": name, + "metadata": { + "created_at": "2024-01-01T00:00:00Z", + "status": "active" + }, + "next_steps": [ + "Configure database settings", + "Add initial collections", + "Set up access permissions" + ] + } \ No newline at end of file