Add ntfy notification for super admin login
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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"}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user