diff options
| author | Dennis Fink | 2026-11-14 18:46:24 +0100 |
|---|---|---|
| committer | Dennis Fink | 2026-11-14 18:46:24 +0100 |
| commit | e52e554e2d033dd5ef8397617644e90e354f9560 (patch) | |
| tree | 6eb15ae02faa096f383ca06aeed0aef5ea51b4a2 /webmentions_ssg | |
| parent | 968e1b4e4a6fbd5a15037cdb11a3f9dee5108570 (diff) | |
| download | webmentions-ssg-e52e554e2d033dd5ef8397617644e90e354f9560.tar.gz webmentions-ssg-e52e554e2d033dd5ef8397617644e90e354f9560.zip | |
refactor(core): inline admin action validation
Remove the single-purpose validation helper and keep each administrative
route's form guard local to the action it protects.
Diffstat (limited to '')
| -rw-r--r-- | webmentions_ssg/views/admin.py | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/webmentions_ssg/views/admin.py b/webmentions_ssg/views/admin.py index b9ab53e..1025e69 100644 --- a/webmentions_ssg/views/admin.py +++ b/webmentions_ssg/views/admin.py @@ -21,15 +21,6 @@ from ..tasks.sender import send_webmention from .blueprint import root_page -def validate_admin_action() -> None: - """Reject invalid administrative action forms with HTTP 400. - - Abort the request when the posted form does not pass CSRF or other validation. - """ - if not forms.AdminActionForm().validate_on_submit(): - abort(400) - - @root_page.route("/received") @login_required def received() -> ResponseReturnValue: @@ -58,7 +49,8 @@ def delete_received_webmention(identifier: uuid.UUID) -> ResponseReturnValue: :param identifier: Identifier of the Webmention to delete. :returns: Redirect response to the received Webmentions view. """ - validate_admin_action() + if not forms.AdminActionForm().validate_on_submit(): + abort(400) webmention = db.get_or_404(ReceivedWebmention, identifier) @@ -82,7 +74,8 @@ def reverify_received_webmention(identifier: uuid.UUID) -> ResponseReturnValue: :param identifier: Identifier of the Webmention to reverify. :returns: Redirect response to the received Webmentions view. """ - validate_admin_action() + if not forms.AdminActionForm().validate_on_submit(): + abort(400) webmention = db.get_or_404(ReceivedWebmention, identifier) @@ -127,7 +120,8 @@ def rescan_sent_sources() -> ResponseReturnValue: :returns: Redirect response to the sent Webmentions view. """ - validate_admin_action() + if not forms.AdminActionForm().validate_on_submit(): + abort(400) manual_scan_sources() flash("Source rescan queued.", "success") @@ -177,7 +171,8 @@ def resend_sent_webmention( :param webmention_identifier: Identifier of the sent Webmention to resend. :returns: Redirect response to the source details view. """ - validate_admin_action() + if not forms.AdminActionForm().validate_on_submit(): + abort(400) webmention = db.get_or_404(SentWebmention, webmention_identifier) |
