fix(auth): empty ADMIN_PASSWORD in .env now falls back to admin; strip passwords

Made-with: Cursor
This commit is contained in:
Андрей Бобырев
2026-04-25 00:40:47 +03:00
parent a2e565d615
commit e1d6e6bb81
3 changed files with 7 additions and 5 deletions

View File

@@ -24,7 +24,7 @@ TPL = Path(__file__).resolve().parent.parent / "templates"
def _chk(pwd: str) -> None:
if config.ADMIN_PASSWORD and pwd != config.ADMIN_PASSWORD:
if (pwd or "").strip() != config.ADMIN_PASSWORD:
raise HTTPException(401, "Неверный пароль")
@@ -44,7 +44,7 @@ async def index():
@app.post("/api/auth")
async def api_auth(b: AuthBody):
if config.ADMIN_PASSWORD and b.password == config.ADMIN_PASSWORD:
if (b.password or "").strip() == config.ADMIN_PASSWORD:
return {"ok": True}
raise HTTPException(401, "Wrong password")