diff --git a/app/admin.py b/app/admin.py index 2dc84b8..c847f62 100644 --- a/app/admin.py +++ b/app/admin.py @@ -1072,9 +1072,21 @@ async def login_validation( password: str = Form(), redirect: str | None = Form(None), csrf_check: None = Depends(verify_csrf_token), -) -> RedirectResponse: + db_session: AsyncSession = Depends(get_db_session), +) -> RedirectResponse | templates.TemplateResponse: if not verify_password(password): - raise HTTPException(status_code=401) + logger.warning("Invalid password") + return await templates.render_template( + db_session, + request, + "login.html", + { + "error": "Invalid password", + "csrf_token": generate_csrf_token(), + "redirect": request.query_params.get("redirect", ""), + }, + status_code=403, + ) resp = RedirectResponse(redirect or "/admin/stream", status_code=302) resp.set_cookie("session", session_serializer.dumps({"is_logged_in": True})) # type: ignore # noqa: E501 diff --git a/app/scss/main.scss b/app/scss/main.scss index a1e8cf2..f572c4b 100644 --- a/app/scss/main.scss +++ b/app/scss/main.scss @@ -13,6 +13,10 @@ $code-highlight-background: #f0f0f0; // Load custom theme @import "theme.scss"; +.primary-color { + color: $primary-color; +} + .show-more-wrapper { .p-summary { display: inline-block; diff --git a/app/templates.py b/app/templates.py index 30bd759..2ba36fa 100644 --- a/app/templates.py +++ b/app/templates.py @@ -90,6 +90,7 @@ async def render_template( request: Request, template: str, template_args: dict[str, Any] | None = None, + status_code: int = 200, ) -> TemplateResponse: if template_args is None: template_args = {} @@ -133,6 +134,7 @@ async def render_template( "actor_types": ap.ACTOR_TYPES, **template_args, }, + status_code=status_code, ) diff --git a/app/templates/login.html b/app/templates/login.html index 7142c05..8a52153 100644 --- a/app/templates/login.html +++ b/app/templates/login.html @@ -3,6 +3,9 @@ {% block content %}
Invalid password.
+{% endif %}