From 23a3e3542f5e43d642775bf684cc23aa989e6307 Mon Sep 17 00:00:00 2001 From: Ari Archer Date: Sat, 8 Jun 2024 21:21:37 +0300 Subject: [PATCH] remove captcha Signed-off-by: Ari Archer --- requirements.txt | 1 - src/aw/__init__.py | 4 ---- src/aw/c.py | 7 ------- src/aw/views.py | 16 ++++------------ src/static/css/index.css | 14 ++------------ src/templates/index.j2 | 10 ---------- 6 files changed, 6 insertions(+), 46 deletions(-) delete mode 100644 src/aw/c.py diff --git a/requirements.txt b/requirements.txt index 49849ec..a470c89 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,6 @@ flask types-flask flask-sqlalchemy -flask-ishuman crc4 validators markdown diff --git a/src/aw/__init__.py b/src/aw/__init__.py index 12ae137..007a3ee 100644 --- a/src/aw/__init__.py +++ b/src/aw/__init__.py @@ -69,10 +69,6 @@ def create_app(name: str) -> flask.Flask: app.register_blueprint(views, url_prefix="/") - from .c import c - - c.init_app(app) - app.jinja_env.filters["markdown"] = util.markdown_to_html # type: ignore web_mini.compileall() diff --git a/src/aw/c.py b/src/aw/c.py deleted file mode 100644 index a6aa029..0000000 --- a/src/aw/c.py +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -"""Captcha""" - -import flask_ishuman - -c: flask_ishuman.IsHuman = flask_ishuman.IsHuman() diff --git a/src/aw/views.py b/src/aw/views.py index a080f28..71a6383 100644 --- a/src/aw/views.py +++ b/src/aw/views.py @@ -11,7 +11,6 @@ import validators from werkzeug.wrappers import Response from . import email, models, util -from .c import c from .routing import Bp views: Bp = Bp("views", __name__) @@ -110,7 +109,9 @@ Deletion token: def delete(comment_id: int, token: str): """delete a comment""" - comment: models.Comment = models.Comment.query.filter_by(id=comment_id, token=token).first_or_404() + comment: models.Comment = models.Comment.query.filter_by( + id=comment_id, token=token + ).first_or_404() models.db.session.delete(comment) models.db.session.commit() @@ -124,13 +125,10 @@ def delete(comment_id: int, token: str): def comment(): """publish a comment""" - for field in "name", "email", "comment", "code": + for field in "name", "email", "comment": if field not in flask.request.form: flask.abort(400) - if not c.verify(flask.request.form["code"]): # type: ignore - flask.abort(403) - if not validators.email(flask.request.form["email"]): flask.abort(400) @@ -273,12 +271,6 @@ def counter() -> flask.Response: ) -@views.get("/captcha.png") -def captcha() -> flask.Response: - """CAPTCHA""" - return flask.Response(c.new().rawpng(), mimetype="image/png") - - @views.get("/badge.png") def badge() -> Response: """Website badge""" diff --git a/src/static/css/index.css b/src/static/css/index.css index c3017b3..093b66c 100644 --- a/src/static/css/index.css +++ b/src/static/css/index.css @@ -101,18 +101,6 @@ form > button { min-height: 3em; } -.captcha { - display: -ms-grid; - display: grid; - place-items: center; - margin: 0.5em; -} - -.captcha > img { - display: block; - cursor: pointer; -} - #comments > div { background-color: #111; padding: 0.5em; @@ -152,10 +140,12 @@ form > button { -ms-flex-align: unset; align-items: unset; } + .split > *:nth-child(1) { -ms-grid-row: 1; -ms-grid-column: 1; } + .split > *:nth-child(2) { -ms-grid-row: 3; -ms-grid-column: 1; diff --git a/src/templates/index.j2 b/src/templates/index.j2 index 2858f6a..ae69341 100644 --- a/src/templates/index.j2 +++ b/src/templates/index.j2 @@ -431,16 +431,6 @@ -
- An image CAPTCHA - Click the image above to reload and get a new CAPTCHA. -
- -
- - -
-