mirror of
https://github.com/andrey271192/keenetic-dns-routes.git
synced 2026-09-20 14:42:01 +00:00
fix(auth): empty ADMIN_PASSWORD in .env now falls back to admin; strip passwords
Made-with: Cursor
This commit is contained in:
@@ -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")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user