canaille-globuzma/oidc_ldap_bridge/forms.py

77 lines
2.4 KiB
Python
Raw Normal View History

2020-08-19 14:20:57 +00:00
import wtforms
2020-10-20 09:44:45 +00:00
from flask_babel import gettext as _
2020-08-19 14:20:57 +00:00
from flask_wtf import FlaskForm
class LoginForm(FlaskForm):
login = wtforms.StringField(
2020-10-20 09:44:45 +00:00
_("Login"),
2020-08-19 14:20:57 +00:00
validators=[wtforms.validators.DataRequired()],
render_kw={
"placeholder": "mdupont",
"spellcheck": "false",
"autocorrect": "off",
"inputmode": "email",
},
2020-08-19 14:20:57 +00:00
)
password = wtforms.PasswordField(
_("Password"),
validators=[wtforms.validators.DataRequired()],
2020-08-19 14:20:57 +00:00
)
2020-10-20 09:44:45 +00:00
class ProfileForm(FlaskForm):
sub = wtforms.StringField(
_("Username"),
render_kw={"readonly": "true"},
)
# name = wtforms.StringField(_("Name"))
2020-10-21 07:52:02 +00:00
given_name = wtforms.StringField(
_("Given name"),
render_kw={
"placeholder": _("John"),
"spellcheck": "false",
"autocorrect": "off",
},
2020-10-21 07:52:02 +00:00
)
family_name = wtforms.StringField(
_("Family Name"),
render_kw={
"placeholder": _("Doe"),
"spellcheck": "false",
"autocorrect": "off",
},
2020-10-21 07:52:02 +00:00
)
2020-10-20 09:44:45 +00:00
# preferred_username = wtforms.StringField(_("Preferred username"))
# gender = wtforms.StringField(_("Gender"))
# birthdate = wtforms.fields.html5.DateField(_("Birth date"))
# zoneinfo = wtforms.StringField(_("Zoneinfo"))
# locale = wtforms.StringField(_("Language"))
2020-10-21 07:52:02 +00:00
email = wtforms.fields.html5.EmailField(
_("Email address"),
validators=[wtforms.validators.DataRequired(), wtforms.validators.Email()],
render_kw={
"placeholder": _("jane@doe.com"),
"spellcheck": "false",
"autocorrect": "off",
},
2020-10-21 07:52:02 +00:00
)
2020-10-20 09:44:45 +00:00
# address = wtforms.StringField(_("Address"))
2020-10-21 07:52:02 +00:00
phone_number = wtforms.fields.html5.TelField(
_("Phone number"), render_kw={"placeholder": _("555-000-555")}
)
2020-10-20 09:44:45 +00:00
# picture = wtforms.StringField(_("Photo"))
# website = wtforms.fields.html5.URLField(_("Website"))
2020-10-21 08:26:31 +00:00
password1 = wtforms.PasswordField(
_("Password"),
validators=[wtforms.validators.Optional(), wtforms.validators.Length(min=8)],
)
password2 = wtforms.PasswordField(
_("Password confirmation"),
)
def validate_password2(self, field):
if self.password1.data and self.password1.data != field.data:
raise wtforms.ValidationError(_("Password and confirmation are different."))