Add ntfy notification for super admin login

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-22 01:26:42 -07:00
parent 090ebc109e
commit 697854e406
2 changed files with 8 additions and 1 deletions

View File

@@ -9,6 +9,7 @@ from app.auth.jwt import create_admin_token, create_access_token, hash_password
from app.config import get_settings
from app.dependencies import get_db, get_admin_user
from app.models.user import User
from app.utils.ntfy import notify
router = APIRouter(prefix="/api/admin", tags=["admin"])
settings = get_settings()
@@ -22,6 +23,12 @@ async def admin_login(body: dict):
logger.warning("Failed super-admin login attempt for username=%s", username)
raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="Invalid admin credentials")
token = create_admin_token({"sub": "admin"})
await notify(
title="Super Admin Login",
message=f"Admin logged in as: {username}",
priority="high",
tags=["key"],
)
return {"access_token": token, "token_type": "bearer"}