Update code in endpoints/login.post.py
This commit is contained in:
parent
508ccb71ec
commit
e9d79b2cc8
@ -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"
|
||||
]
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user