From 838a5732ea0a8e522c0864789086a2b54bb24db9 Mon Sep 17 00:00:00 2001 From: Massimo Di Pierro Date: Sun, 4 Aug 2024 10:48:38 -0400 Subject: [PATCH] allow passing template_args to Auth temaplates, thanks kszys --- py4web/utils/auth.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/py4web/utils/auth.py b/py4web/utils/auth.py index f7d6e5d1..37d52ae7 100644 --- a/py4web/utils/auth.py +++ b/py4web/utils/auth.py @@ -13,7 +13,7 @@ from yatl.helpers import DIV, A from py4web import HTTP, URL, Field, action, redirect, request, response -from py4web.core import REGEX_APPJSON, Fixture, Flash, Translator +from py4web.core import REGEX_APPJSON, Fixture, Flash, Template, Translator from py4web.utils.form import Form, FormStyleDefault from py4web.utils.param import Param @@ -230,6 +230,7 @@ def __init__( password_in_db=True, two_factor_required=None, two_factor_send=None, + template_args=None, ): # configuration parameters self.param = Param( @@ -256,6 +257,7 @@ def __init__( two_factor_send=two_factor_send, two_factor_tries=3, auth_enforcer=None, + template_args=template_args or {}, ) # callbacks for forms @@ -1064,10 +1066,9 @@ def _(path, plugin=self.plugins[name], name=name): for item in exposed_form_routes: form_factory = getattr(self.form_source, item["form_name"]) - + template = Template(f"{route}.html", **self.param.template_args) @action(item["form_route"], method=["GET", "POST"]) - @action.uses(f"{route}.html") - @action.uses(item["uses"], self.flash, *uses) + @action.uses(template, item["uses"], self.flash, *uses) def _( auth=auth, form_factory=form_factory,