text: from flask_wtf import FlaskForm
  from wtforms import StringField, PasswordField, SubmitField, BooleanField
  from wtforms import ValidationError
  from wtforms.validators import DataRequired, Length, Email, EqualTo, Regexp
  
  from noirart.models import User
  
  
  class LoginForm(FlaskForm):
      email = StringField('Email', validators=[DataRequired(), Length(1, 254), Email()])
      password = PasswordField('Password', validators=[DataRequired()])
      remember_me = BooleanField('Remember me')
      submit = SubmitField('Log in')
  
  
  class RegisterForm(FlaskForm):
      name = StringField('Name', validators=[DataRequired(), Length(1, 30)])
      email = StringField('Email', validators=[DataRequired(), Length(1, 254), Email()])
      # 通过username创建个人域名空间，所以不能重复，字符必须为数字字母in
      username = StringField('Username', validators=[DataRequired(), Length(1, 20),
                                                     Regexp('^[a-zA-Z0-9]*$',
                                                            message='The username should contain only a-z, A-Z and 0-9.')])
      password = PasswordField('Password', validators=[
          DataRequired(), Length(8, 128), EqualTo('password2')])
      password2 = PasswordField('Confirm password', validators=[DataRequired()])
      submit = SubmitField()
  
      def validate_email(self, field):
          if User.query.filter_by(email=field.data).first():
              raise ValidationError('The email is already in use.')
  
      def validate_username(self, field):
          if User.query.filter_by(username=field.data).first():
              raise ValidationError('The username is already in use.')
  
  
  class ForgetPasswordForm(FlaskForm):
      email = StringField('Email', validators=[DataRequired(), Length(1, 254), Email()])
      submit = SubmitField()
  
  
  class ResetPasswordForm(FlaskForm):
      email = StringField('Email', validators=[DataRequired(), Length(1, 254), Email()])
      password = PasswordField('Password', validators=[
          DataRequired(), Length(8, 128), EqualTo('password2')])
      password2 = PasswordField('Confirm password', validators=[DataRequired()])
      submit = SubmitField()
  