diff options
Diffstat (limited to 'webmentions_ssg/views/admin.py')
| -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) |
