examples/auth_forms.py
from py4web import action
from .common import T, auth, db, session
@action("auth_forms", method=["GET", "POST"])
@action.uses("examples/auth_forms.html", db, session, T, auth)
def auth_forms():
disabled = False
# this is experimntal, we must disable forms that require a logged in user
if not auth.is_logged_in:
disabled = "disabled"
return dict(
register_form=auth.form("register"),
login_form=auth.form("login"),
reset_password_form=auth.form("reset_password"),
change_password_form=disabled or auth.form("change_password"),
profile_form=disabled or auth.form("profile"),
)
templates/examples/auth_forms.html
[[extend 'layout.html']]
<h2 style="color:red">WORK IN PROGRESS</h2>
<h2>Register Form</h2>
(or <a href="[[=URL('auth_form/register')]]">individual form</a>")
[[=register_form]]
<h2>Login Form</h2>
(or <a href="[[=URL('auth_form/login')]]">individual form</a>")
[[=login_form]]
<h2>Reset Password Form</h2>
(or <a href="[[=URL('auth_form/reset_password')]]">individual form</a>")
[[=reset_password_form]]
<h2>Change Password Form</h2>
(or <a href="[[=URL('auth_form/change_password')]]">individual form</a>")
[[=change_password_form]]
<h2>Profile Form</h2>
(or <a href="[[=URL('auth_form/profile')]]">individual form</a>")
[[=profile_form]]