All checks were successful
Deploy Development / deploy (push) Successful in 35s
Test Suite / pytest-backend (push) Successful in 9s
Test Suite / lint-backend (push) Successful in 2s
Test Suite / compose-smoke (push) Has been skipped
Test Suite / k6 /api/health Baseline (push) Successful in 18s
Test Suite / playwright-smoke (push) Successful in 13s
Co-authored-by: Cursor <cursoragent@cursor.com>
29 lines
790 B
Python
29 lines
790 B
Python
"""Auth endpoints: login, logout."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from auth import login, logout, require_auth
|
|
from fastapi import APIRouter, Depends, Response
|
|
from pydantic import BaseModel, Field
|
|
|
|
router = APIRouter(prefix="/api/auth", tags=["auth"])
|
|
|
|
|
|
class LoginRequest(BaseModel):
|
|
# str statt EmailStr: Self-Hosted/Dev nutzt oft .local-Domains (admin@kairo.local)
|
|
email: str = Field(min_length=3, max_length=255)
|
|
password: str = Field(min_length=8, max_length=256)
|
|
|
|
|
|
@router.post("/login")
|
|
def auth_login(body: LoginRequest):
|
|
return login(body.email, body.password)
|
|
|
|
|
|
@router.post("/logout")
|
|
def auth_logout(response: Response, session: dict = Depends(require_auth)):
|
|
token = session.get("token")
|
|
if token:
|
|
logout(token)
|
|
return {"ok": True}
|