remove captcha

Signed-off-by: Ari Archer <ari@ari.lt>
This commit is contained in:
Arija A. 2024-06-08 21:21:37 +03:00
parent d1ffe5aa98
commit 23a3e3542f
6 changed files with 6 additions and 46 deletions

View file

@ -1,7 +1,6 @@
flask
types-flask
flask-sqlalchemy
flask-ishuman
crc4
validators
markdown

View file

@ -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()

View file

@ -1,7 +0,0 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Captcha"""
import flask_ishuman
c: flask_ishuman.IsHuman = flask_ishuman.IsHuman()

View file

@ -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"""

View file

@ -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;

View file

@ -431,16 +431,6 @@
<textarea required type="text" id="comment" name="comment" placeholder="Hello! I like your website - &lt;https://ari.lt/&gt;."></textarea>
</div>
<div class="captcha">
<img loading="lazy" width="240px" height="90" src="{{ url_for("views.captcha") }}?new" onclick="this.src=this.src+Math.floor(1000*Math.random())" alt="An image CAPTCHA" />
<i>Click the image above to reload and get a new CAPTCHA.</i>
</div>
<div class="form-group">
<label for="captcha">CAPTCHA:</label>
<input required type="text" id="code" name="code" placeholder="Enter the CAPTCHA code above." />
</div>
<div class="form-group">
<label for="agree">Email Policy Agreement:</label>
<input required type="checkbox" id="agree" name="agree" />