add aurweb.captcha, a CAPTCHA utility module

This CAPTCHA workflow is the same workflow used by our current
PHP implementation of account registration.

Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
Kevin Morris 2021-01-28 16:52:56 -08:00
parent 7a6a38592e
commit df0a637d2b
3 changed files with 119 additions and 1 deletions

View file

@ -12,7 +12,7 @@ from fastapi.responses import HTMLResponse
import aurweb.config
from aurweb import l10n, time
from aurweb import captcha, l10n, time
# Prepare jinja2 objects.
loader = jinja2.FileSystemLoader(os.path.join(
@ -23,6 +23,10 @@ env = jinja2.Environment(loader=loader, autoescape=True,
# Add tr translation filter.
env.filters["tr"] = l10n.tr
# Add captcha filters.
env.filters["captcha_salt"] = captcha.captcha_salt_filter
env.filters["captcha_cmdline"] = captcha.captcha_cmdline_filter
def make_context(request: Request, title: str, next: str = None):
""" Create a context for a jinja2 TemplateResponse. """