Source code for user.forms.registration
from onegov.form import Form
from onegov.user import _
from onegov.user.collections import MIN_PASSWORD_LENGTH
from wtforms.fields import PasswordField
from wtforms.fields import StringField
from wtforms.validators import Email
from wtforms.validators import EqualTo
from wtforms.validators import InputRequired
from wtforms.validators import Length
[docs]
class RegistrationForm(Form):
""" A generic registration form for onegov.user """
[docs]
password = PasswordField(
label=_('Password'),
validators=[
InputRequired(),
Length(min=MIN_PASSWORD_LENGTH, message=_(
'The password must be at least eight characters long'
))
]
)
[docs]
confirm = PasswordField(
label=_('Password Confirmation'),
validators=[InputRequired(), EqualTo(
'password', message=_('Passwords must match')
)]
)
# To avoid the most basic spam bots we present a field which the user
# should not fill. We'll actually hide this field from the user. Bots
# tend to fill out all fields. If they do they won't succeed.
#
# This however won't deterr a targeted attack. We'll have to see if we
# need a more sophisticated approach in the future.
[docs]
roboter_falle = StringField(
label=_('Please leave this field empty'),
validators=[Length(max=0, message=_(
'The field is not empty'
))]
)