예제 #1
0
class ForgotPasswordForm(Form):
    email = StringField(
        _('Email address'),
        validators=[
            DataRequired(message=_("A valid email address is required.")),
            Email()
        ])

    recaptcha = RecaptchaField(_("Captcha"))

    submit = SubmitField(_("Request Password"))
예제 #2
0
class RegisterForm(Form):
    username = StringField(
        _("Username"),
        validators=[
            DataRequired(message=_("A valid username is required.")),
            is_username
        ])

    email = StringField(
        _("Email address"),
        validators=[
            DataRequired(message=_("A valid email address is required.")),
            Email(message=_("Invalid email address."))
        ])

    password = PasswordField(_('Password'),
                             validators=[
                                 InputRequired(),
                                 EqualTo('confirm_password',
                                         message=_('Passwords must match.'))
                             ])

    confirm_password = PasswordField(_('Confirm password'))

    recaptcha = RecaptchaField(_("Captcha"))

    language = SelectField(_('Language'))

    accept_tos = BooleanField(_("I accept the Terms of Service"), default=True)

    submit = SubmitField(_("Register"))

    def validate_username(self, field):
        user = User.query.filter_by(username=field.data).first()
        if user:
            raise ValidationError(_("This username is already taken."))

    def validate_email(self, field):
        email = User.query.filter_by(email=field.data).first()
        if email:
            raise ValidationError(_("This email address is already taken."))

    def save(self):
        user = User(username=self.username.data,
                    email=self.email.data,
                    password=self.password.data,
                    date_joined=time_utcnow(),
                    primary_group_id=4,
                    language=self.language.data)
        return user.save()
예제 #3
0
class LoginForm(Form):
    login = StringField(
        _("Username or Email address"),
        validators=[
            DataRequired(
                message=_("Please enter your username or email address."))
        ])

    password = PasswordField(
        _("Password"),
        validators=[DataRequired(message=_("Please enter your password."))])

    recaptcha = RecaptchaField(_("Captcha"))

    remember_me = BooleanField(_("Remember me"), default=False)

    submit = SubmitField(_("Login"))
예제 #4
0
class LoginForm(Form):
    login = StringField(
        _("Username or E-Mail Address"),
        validators=[
            DataRequired(
                message=_("A Username or E-Mail Address is required."))
        ])

    password = PasswordField(
        _("Password"),
        validators=[DataRequired(message=_("A Password is required."))])

    recaptcha = RecaptchaField(_("Captcha"))

    remember_me = BooleanField(_("Remember Me"), default=False)

    submit = SubmitField(_("Login"))