From e9d79b2cc8f9a13bae756da6fe047569b69aa63e Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Thu, 20 Mar 2025 13:08:52 +0000 Subject: [PATCH] Update code in endpoints/login.post.py --- endpoints/login.post.py | 59 +++++++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 17 deletions(-) diff --git a/endpoints/login.post.py b/endpoints/login.post.py index df5aa08..42c1ef5 100644 --- a/endpoints/login.post.py +++ b/endpoints/login.post.py @@ -1,25 +1,50 @@ from fastapi import APIRouter, Depends, HTTPException -from core.auth import get_current_user_dummy from core.database import fake_users_db +import uuid +from typing import Optional router = APIRouter() -@router.post("/login") -async def login_demo( - username: str = "demo", - password: str = "password" +@router.post("/api/employees") +async def create_employee( + name: str, + position: str, + email: str, + department: Optional[str] = None, + salary: Optional[float] = None ): - """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 employee record""" + employee_id = str(uuid.uuid4()) + + if email in [emp.get("email") for emp in fake_users_db.values()]: + raise HTTPException(status_code=400, detail="Employee with this email already exists") + + employee_data = { + "id": employee_id, + "name": name, + "position": position, + "email": email, + "department": department, + "salary": salary, + "active": True + } + + fake_users_db[employee_id] = employee_data return { - "message": "Login successful (demo)", - "user": username, - "token": "dummy_jwt_token_123", - "features": { - "rate_limit": 100, - "expires_in": 3600 - } - } + "message": "Employee created successfully", + "data": { + "employee_id": employee_id, + "name": name, + "email": email + }, + "metadata": { + "created_at": "demo_timestamp", + "department": department + }, + "next_steps": [ + "Complete employee onboarding", + "Assign access credentials", + "Schedule orientation" + ] + } \ No newline at end of file