Skip to content

Commit

Permalink
allow passing template_args to Auth temaplates, thanks kszys
Browse files Browse the repository at this point in the history
  • Loading branch information
mdipierro committed Aug 4, 2024
1 parent fb0df93 commit 838a573
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions py4web/utils/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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(
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 838a573

Please sign in to comment.