コード例 #1
0
class RegisterForm(BaseForm):
    username = StringField(
        label='用户名',
        validators=[
           DataRequired(),
            validators.Length(2, 15, message='昵称至少需要两个字符,最多15个字符')
        ],
        widget=widgets.TextInput(),
        render_kw={'class': 'form-control'},
        default='root'
    )

    password = simple.PasswordField(
        label='密码',
        validators=[
            validators.DataRequired(message='密码不能为空.')
        ],
        widget=widgets.PasswordInput(),
        render_kw={'class': 'form-control'}
    )

    pwd_confirm = simple.PasswordField(
        label='重复密码',
        validators=[
            validators.DataRequired(message='重复密码不能为空.'),
            validators.EqualTo('password', message="两次密码输入不一致")
        ],
        widget=widgets.PasswordInput(),
        render_kw={'class': 'form-control'}
    )

    def validate_username(self, field):
        if User.query.filter_by(username=field.data).first():
            raise validators.ValidationError('用户名已存在')
コード例 #2
0
class RegistrationForm(Form):
    username = simple.StringField(
        label='Username',
        widget=widgets.TextInput(),
        validators=[
            validators.DataRequired(message="Username can not be empty"),
            validators.Length(6, 40, 'Need to be more than 6 characters')
        ])
    password = simple.PasswordField(
        label='Password',
        widget=widgets.PasswordInput(),
        validators=[
            validators.DataRequired(message='Password can not be empty'),
            validators.Length(6, 40, 'Need to be more than 6 characters')
        ])
    password2 = simple.PasswordField(
        label='Repeat Password',
        widget=widgets.PasswordInput(),
        validators=[
            validators.DataRequired(message='Password can not be empty'),
            validators.EqualTo('password', message='Two password not same')
        ])
    email = simple.StringField(
        label='Email',
        widget=widgets.TextInput(),
        validators=[
            validators.DataRequired(message='Email can not be empty'),
            validators.Email(message='Wrong Email Syntax')
        ])
    submit = simple.SubmitField(label='Submit', widget=widgets.SubmitInput())
コード例 #3
0
class RegisterForm(FlaskForm):
    username = simple.StringField(label="请输入用户名:",
    validators=[
        validators.DataRequired(message="用户名不能为空"),
        validators.Length(min=6, max=18, message='用户名长度必须大于%(min)d,且小于%(max)d')
    ],
    widget=widgets.TextInput(),render_kw={"class":"form-control"}
    )
    password = simple.StringField(label="请输入密码:",
    validators=[
        validators.DataRequired(message="密码不能为空"),
        validators.Length(min=8,message="密码至少%(min)d位"),
        validators.Regexp(regex="^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)"
                                "[A-Za-z\d~!@#$%^&*()_+]{8,}",
                          message="密码至少包含1个小写和大写字母以及1个数字")
    ],
    widget=widgets.PasswordInput(),render_kw={"class":"form-control"})
    # 确认密码
    password2 = simple.StringField(label="请确认密码:",
    validators=[
        validators.DataRequired(message="请确认您的密码"),
        EqualTo("password",message="两次密码输入不一致")
    ],
    widget=widgets.PasswordInput(),render_kw={"class":"form-control",
                                              "placeholder":"确认密码"}
    )
コード例 #4
0
class RegisterForm(Form):
    telephone = fields.StringField(
        label='用户名',
        validators=[
            validators.DataRequired(message='电话号码不能为空'),
            validators.length(min=6, max=11, message='电话号长度不满足条件')
        ],
        widget=widgets.TextInput(),  # 表示是一个文本控件
        render_kw={
            'class': 'form-control',
            'placeholder': '请输入用户名',
            'required': '',
            'autofocus': ''
        }
    )
    username = fields.StringField(
        label='用户名',
        validators=[
            validators.DataRequired(message='用户名不能为空'),
        ],
        widget=widgets.TextInput(),
        render_kw={
            'class': 'form-control',
            'placeholder': '请输入用户名字',
            'required': '',
            'autofocus': ''
        }
    )
    password1 = fields.PasswordField(
        label='密码',
        validators=[
            validators.DataRequired(message='密码不能为空'),
            validators.length(min=6, message='密码必须大于%(min)d位')
        ],
        widget=widgets.PasswordInput(),
        render_kw={
            'class': 'form-control',
            'placeholder': '请确认密码',
            'required': '',
            'autofocus': ''
        }
    )

    password2 = fields.PasswordField(
        label='确认密码',
        validators=[
            validators.DataRequired(message='密码不能为空'),
            validators.length(min=6, message='密码必须大于%(min)d位')
        ],
        widget=widgets.PasswordInput(),
        render_kw={
            'class': 'form-control',
            'placeholder': '请确认密码',
            'required': '',
            'autofocus': ''
        }
    )
コード例 #5
0
class RegistForm(FlaskForm):
    """用户注册表单"""
    name = StringField(label='昵称',
                       validators=[
                           validators.DataRequired("请输入用户名!."),
                           validators.DataRequired(message='用户名不能为空.'),
                           validators.Length(min=4, message='用户名长度必须大于%(min)d')
                       ],
                       widget=widgets.TextInput(),
                       render_kw={
                           'class': 'loginuser',
                           "placeholder": "请输入用户名!"
                       })
    pwd = PasswordField(label='密码',
                        validators=[
                            validators.DataRequired("请输入密码!."),
                            validators.DataRequired(message='密码不能为空.'),
                            validators.Length(min=6,
                                              message='用户名长度必须大于%(min)d'),
                            validators.Regexp(regex="^(?=.*[a-z])(?=.*\d){6,}",
                                              message='密码至少6个字符,1个大小写字母和1个数字符')
                        ],
                        widget=widgets.PasswordInput(),
                        render_kw={
                            'class': 'loginuser',
                            "placeholder": "请输入密码!"
                        })
    repwd = PasswordField(
        label='确认密码',
        validators=[
            validators.DataRequired("请输入密码!."),
            validators.DataRequired(message='密码不能为空.'),
            validators.EqualTo('pwd', message="两次密码不是一致!"),
            validators.Length(min=6, message='用户名长度必须大于%(min)d'),
            # validators.Regexp(regex="^(?=.*[a-z])(?=.*\d)(?=.*[$@$!%*?&])[A-Za-z\d$@$!%*?&]{6,}",
            #                   message='密码至少8个字符,至少1个大写字母,1个小写字母,1个数字和1个特殊字符')
            validators.Regexp(regex="^(?=.*[A-Za-z])(?=.*\d){6,}",
                              message='密码至少6个字符,1个大小写字母和1个数字符')
        ],
        widget=widgets.PasswordInput(),
        render_kw={
            'class': 'loginuser',
            "placeholder": "请确认密码!"
        })
    submit = SubmitField(label='登录', render_kw={"class": "loginbtn"})
    select1 = BooleanField(label='1', )
    select2 = BooleanField(label='2', )
    select3 = BooleanField(label='3', )

    def validate_name(self, field):
        name = field.data
        user = User.query.filter_by(name=name).count()
        if user == 1:
            raise validators.ValidationError("用户名已存在")
コード例 #6
0
class RegisterForm(Form):
    username = simple.StringField(
        label='用户名',
        validators=[
            validators.DataRequired(message='用户名不能为空'),
            validators.Length(min=3,
                              max=18,
                              message='用户名长度必须大于%(min)d, 并且小于%(max)d'),
        ],
        widget=widgets.TextInput(),
        render_kw={'class': 'form-control'})
    pwd = simple.PasswordField(
        label='用户密码',
        validators=[
            validators.DataRequired(message='用户密码不能为空'),
            validators.Length(min=6,
                              max=18,
                              message='用户密码的长度必须大于6位字符并且小于18位字符'),
            validators.Regexp(
                regex='^(?=.*[a-zA-Z])(?=.*[0-9])(?=.*[_]){6,18}',
                message='用户密码至少包'
                '含一个字母一个数字以及一个下划线')
        ],
        widget=widgets.PasswordInput(),
        render_kw={'class': 'form-control'},
    )
    re_pwd = simple.PasswordField(
        label='重复密码',
        validators=[
            validators.DataRequired(message='重复密码不能为空'),
            validators.EqualTo('pwd', '两次密码输入不一致')
        ],
        widget=widgets.PasswordInput(),
        render_kw={'class': 'control'},
    )
    email = html5.EmailField(
        label='邮箱',
        validators=[
            validators.DataRequired(message='邮箱不能为空'),
            validators.Email(message='邮箱格式错误')
        ],
        widget=widgets.TextInput(input_type='email'),
        render_kw={'class': 'form-control'},
    )

    def __init__(self, *args, **kwargs):
        super(RegisterForm, self).__init__(*args, **kwargs)

    def validate_pwd_confirm(self, field):
        if field.data != self.data['pwd']:
            # raise validators.ValidationError("密码不一致")  继续后续验证
            raise validators.StopValidation('密码不一致')  # 不再继续验证
コード例 #7
0
class UserDetailsForm(FlaskForm):
    username = fields.StringField(_('Username'))
    email = fields.StringField(
        _('Email'), validators=[validators.DataRequired(),
                                validators.Email()])
    password = fields.StringField(
        _('Password'),
        validators=[validators.EqualTo('password_confirm')],
        widget=widgets.PasswordInput())
    password_confirm = fields.StringField(_('Confirm Password'),
                                          widget=widgets.PasswordInput())
    locale = fields.SelectField(_('Language'),
                                choices=constants.LANGUAGE_CHOICES)

    def __init__(self, *args, **kwargs):
        self.instance = kwargs.get('instance')

        if self.instance:
            initial_data = {
                'email': self.instance.email,
                'locale': self.instance.locale,
                'username': self.instance.username,
            }

            kwargs.update(data=initial_data)

        super().__init__(*args, **kwargs)

    def validate_username(self, field):
        deployment = self.instance.deployment if self.instance else None
        args = [models.User.username == field.data]
        if deployment:
            args.append(models.User.deployment_id == deployment.id)
        if self.instance:
            args.append(models.User.id != self.instance.id)

        if services.users.query.filter(exists().where(and_(*args))).scalar():
            raise validators.ValidationError(
                _('The username %(username)s is not available',
                  username=field.data))

    def validate_email(self, field):
        deployment = self.instance.deployment if self.instance else None
        args = [models.User.email == field.data]
        if deployment:
            args.append(models.User.deployment_id == deployment.id)
        if self.instance:
            args.append(models.User.id != self.instance.id)

        if services.users.query.filter(exists().where(and_(*args))).scalar():
            raise validators.ValidationError(
                _('The email %(email)s is not available', email=field.data))
コード例 #8
0
class UserForm(BaseSecureForm):
    """User form
       Note: no need to add a 'users' field.  Use the user_editor panel (in a template) instead
       Only need to initialize as a secure form to generate CSRF token
    """
    # these fields used for new user form
    random_password = wtforms.BooleanField(label=_(u"Create and download random password"), default="checked")
    access_keys = wtforms.BooleanField(label=_(u"Create and download access keys"), default="checked")
    allow_all = wtforms.BooleanField(label=_(u"Allow read/write access to all resource except users and groups"))

    path = TextEscapedField(label=_(u"Path"), default="/")

    # additional items used for update user form
    user_name = wtforms.TextField(label=_(u"Name"))
    email = wtforms.TextField(label=_(u"E-mail address"))
    new_password = wtforms.PasswordField(
        _(u'New password'),
        validators=[
            validators.InputRequired(message=_(u'New Password is required')),
            validators.Length(min=6, message=_(u'Password must be more than 6 characters'))
        ],
        widget=widgets.PasswordInput())
    new_password2 = wtforms.PasswordField(
        _(u'Confirm new password'),
        validators=[
            validators.InputRequired(message=_(u'New Password is required')),
            validators.Length(min=6, message=_(u'Password must be more than 6 characters'))
        ],
        widget=widgets.PasswordInput())

    download_keys = wtforms.BooleanField(label=_(u"Download keys after generation"))

    as_account = wtforms.SelectField()

    def __init__(self, request, user=None, iam_conn=None, account=None, **kwargs):
        super(UserForm, self).__init__(request, **kwargs)
        self.user = user
        if user is not None:
            self.user_name.data = user.user_name
            self.path.data = user.path
        else:
            if iam_conn is not None:
                self.as_account.choices = ChoicesManager(iam_conn).accounts(add_blank=False)
                if account is not None:
                    self.as_account.data = ''
                    # set current account value to '' so detecting default value is simpler
                    for idx, val in enumerate(self.as_account.choices):
                        val1, val2 = val
                        if val1 == account:
                            self.as_account.choices[idx] = ('', account)
コード例 #9
0
ファイル: app11.py プロジェクト: dteer/flask_study
class RegisterForm(Form):
    name = simple.StringField(
        label='用户名',
        validators=[
            validators.DataRequired()
        ],
        widget=widgets.TextInput(),
        render_kw={'class': 'form-control'},
        default='alex'
    )

    pwd = simple.PasswordField(
        label='密码',
        validators=[
            validators.DataRequired(message='密码不能为空')
        ],
        widget=widgets.PasswordInput(),
        render_kw={'class': 'form-control'}
    )

    pwd_confirm = simple.PasswordField(
        label='重复密码',
        validators=[
            validators.DataRequired(message='重复密码不能为空'),
            validators.EqualTo('pwd', message='两次密码输入不一致'),
        ],
        widget=widgets.PasswordInput(),
        render_kw={'class': 'form-control'}
    )

    email = html5.EmailField(
        label='邮箱',
        validators=[
            validators.DataRequired(message='邮箱不能为空'),
            validators.Email(message='邮箱格式错误')
        ],
        widget=widgets.TextInput(input_type='email'),
        render_kw={'class': 'from-control'},
    )

    gender = core.RadioField(
        label='性别',
        choices=(
            (1, '男'),
            (2, '女'),
        ),

        coerce=int,
        default=[1, ],
    )
コード例 #10
0
class LoginForm(Form):

    #不同的字段 内部包含正则表达式 html5.EmailField | html5.DateTimeField...
    name=StringField(
        label='用户名',
        validators=[                                #验证规则和错误提示信息
            validators.DataRequired(message='用户名不能为空.'),
            validators.Length(min=6, max=18, message='用户名长度必须大于%(min)d且小于%(max)d')
        ],
        widget=widgets.TextInput(),                 #前端页面显示的插件.TextArea
        render_kw={'class': 'models-control'}      #设置form标签的class信息

        )

    # 不同的字段 内部包含正则表达式  html5.EmailField | html5.DateTimeField...
    pwd = PasswordField(
        label='密码',
        validators=[
            validators.DataRequired(message='密码不能为空.'),
            validators.Length(min=8, message='用户名长度必须大于%(min)d'),
            #自定义验证规则
            validators.Regexp(regex="^(?=.*[a-z])(?=.*\d)[a-z\d]{8,}",
                              message='密码至少8个字符,1个小写字母,1个数字')

        ],
        widget=widgets.PasswordInput(),
        render_kw={'class': 'models-control'}
    )
コード例 #11
0
ファイル: user.py プロジェクト: wuyuz/ChatTools
class LoginForm(Form):
    # 字段(内部包含正则表达式)
    name = simple.StringField(
        label='用户名',
        validators=[
            # 内部校验器
            validators.DataRequired(message='用户名不能为空.'),
            validators.Length(min=2,
                              max=18,
                              message='用户名长度必须大于%(min)d且小于%(max)d')
        ],
        # 页面的显示插件
        widget=widgets.TextInput(),
        # 给插件添加的属性
        # render_kw={'class': 'form-control'}
    )
    # pwd = html5.EmailField() # 可以使用html5的验证方式
    pwd = simple.PasswordField(
        label='密码',
        validators=[
            validators.DataRequired(message='密码不能为空.'),
            validators.Length(min=2, message='用户名长度必须大于%(min)d'),
        ],
        widget=widgets.PasswordInput(),
        # render_kw={'class': 'form-control'}
    )
コード例 #12
0
ファイル: form.py プロジェクト: cpfyjjs/python
class LoginForm(Form):
    name = fields.StringField(
        label="用户名",
        validators=[
            validators.DataRequired(message="用户名不能为空"),
            validators.Length(min=3,
                              max=32,
                              message="用户名长度必须大于%(min)d且小于%(max)d"),
        ],
        widget=widgets.TextInput(),
        render_kw={'class': 'form-control'},
    )

    pwd = fields.PasswordField(
        label="密码",
        validators=[
            validators.DataRequired(message="密码不能为空"),
            validators.Length(min=8,
                              max=32,
                              message='密码长度必须大于%(min)d且小于%(max)d'),
            # validators.Regexp(regex="^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[$@$!%*?&])[A-Za-z\d$@$!%*?&]{8,}",
            #                   message='密码至少8个字符,至少1个大写字母,1个小写字母,1个数字和1个特殊字符'),
        ],
        widget=widgets.PasswordInput(),
        render_kw={'class': 'form-control'},
    )
コード例 #13
0
class LoginForm(BaseForm):
    username = StringField(
        label='用户名',
        validators=[
            DataRequired(),
            validators.Length(2, 15, message='昵称至少需要两个字符,最多15个字符')
        ],
        widget=widgets.TextInput(),
        render_kw={'class': 'form-control'},
        default='root'
    )

    password = simple.PasswordField(
        label='密码',
        validators=[
            validators.DataRequired(message='密码不能为空.')
        ],
        widget=widgets.PasswordInput(),
        render_kw={'class': 'form-control'}
    )

    def validate_username(self, field):
        user = User.query.filter_by(username=field.data).first()
        if not user:
            raise validators.ValidationError('用户名不存在')
        elif not user.is_active:
            raise validators.ValidationError("用户账户未启用")
コード例 #14
0
ファイル: forms.py プロジェクト: dgtlmoon/changedetection.io
class SaltyPasswordField(StringField):
    widget = widgets.PasswordInput()
    encrypted_password = ""

    def build_password(self, password):
        import hashlib
        import base64
        import secrets

        # Make a new salt on every new password and store it with the password
        salt = secrets.token_bytes(32)

        key = hashlib.pbkdf2_hmac('sha256', password.encode('utf-8'), salt, 100000)
        store = base64.b64encode(salt + key).decode('ascii')

        return store

    # incoming
    def process_formdata(self, valuelist):
        if valuelist:
            # Be really sure it's non-zero in length
            if len(valuelist[0].strip()) > 0:
                self.encrypted_password = self.build_password(valuelist[0])
                self.data = ""
        else:
            self.data = False
コード例 #15
0
class LoginForm(Form):
    '''Form'''
    name = simple.StringField(
        label="用户名",
        widget=widgets.TextInput(),
        validators=[
            validators.DataRequired(message="用户名不能为空"),
            validators.Length(max=8,
                              min=3,
                              message="用户名长度必须大于%(max)d且小于%(min)d")
        ],
        render_kw={"class": "form-control"}  # 设置属性生成的html属性
    )

    pwd = simple.PasswordField(label="密码",
                               validators=[
                                   validators.DataRequired(message="密码不能为空"),
                                   validators.Length(
                                       max=18,
                                       min=4,
                                       message="密码长度必须大于%(max)d且小于%(min)d"),
                                   validators.Regexp(regex="\d+",
                                                     message="密码必须是数字"),
                               ],
                               widget=widgets.PasswordInput(),
                               render_kw={"class": "form-control"})
コード例 #16
0
ファイル: forms.py プロジェクト: suyang023/School_Shop
class LoginFrom(FlaskForm):
    """管理员登录表单"""
    account = StringField(label='用户名',
                          validators=[
                              validators.DataRequired("请输入用户名!."),
                              validators.DataRequired(message='用户名不能为空.'),
                          ],
                          widget=widgets.TextInput(),
                          render_kw={
                              'class': 'form-control',
                              "placeholder": "请输入用户名!"
                          })

    pwd = PasswordField(label='密码',
                        validators=[
                            validators.DataRequired("请输入密码!."),
                            validators.DataRequired(message='密码不能为空.'),
                        ],
                        widget=widgets.PasswordInput(),
                        render_kw={
                            'class': 'form-control',
                            "placeholder": "请输入密码!"
                        })
    submit = SubmitField(label='登录', render_kw={"class": "logC"})

    #帐号查询语句
    def validate_account(self, field):
        account = field.data
        admin = Admin.query.filter_by(name=account).count()
        if admin == 0:
            raise ValidationError("帐号不存在!")
コード例 #17
0
class LoginForm(Form):
    # 字段(内部包含正则表达式)
    name = simple.StringField(
        label='用户名',
        validators=[
            validators.DataRequired(message='用户名不能为空.'),
            validators.Length(min=6,
                              max=18,
                              message='用户名长度必须大于%(min)d且小于%(max)d')
        ],
        widget=widgets.TextInput(),  # 页面上显示的插件
        render_kw={'class': 'form-control'})
    # 字段(内部包含正则表达式)
    pwd = simple.PasswordField(
        label='密码',
        validators=[
            validators.DataRequired(message='密码不能为空.'),
            validators.Length(min=8, message='用户名长度必须大于%(min)d'),
            validators.Regexp(
                regex=
                "^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[$@$!%*?&])[A-Za-z\d$@$!%*?&]{8,}",
                message='密码至少8个字符,至少1个大写字母,1个小写字母,1个数字和1个特殊字符')
        ],
        widget=widgets.PasswordInput(),
        render_kw={'class': 'form-control'})
コード例 #18
0
class MyForm(FlaskForm):
    Username = fields.StringField(
        label='用户名1',
        validators=[
            validators.DataRequired(message='用户名不能为空'),
            validators.length(min=6, max=11, message='用户名长度必须大于%(min)d且小于%(max)d')
        ],
        widget=widgets.TextInput(),
        render_kw={
            'class': 'form-control',
            'placeholder': '请输入用户名1',
            'required': '',
            'autofocus': ''
        }
    )
    Password = fields.PasswordField(
        label='密码',
        validators=[
            validators.DataRequired(message='密码不能为空'),
            validators.length(min=6, message='密码必须大于%(min)d位')
        ],
        widget=widgets.PasswordInput(),
        render_kw={
            'class': 'form-control',
            'placeholder': '请输入密码',
            'required': '',
            'autofocus': ''
        }
    )
コード例 #19
0
class LoginFrom(FlaskForm):
    """用户登录表单"""
    account = StringField(label='用户名',
                          validators=[
                              validators.DataRequired("请输入用户名!."),
                              validators.DataRequired(message='用户名不能为空.'),
                              validators.Length(min=4,
                                                message='用户名长度必须大于%(min)')
                          ],
                          widget=widgets.TextInput(),
                          render_kw={
                              'class': 'loginusername',
                              "placeholder": "请输入用户名!"
                          })
    pwd = PasswordField(label='密码',
                        validators=[
                            validators.DataRequired("请输入密码!."),
                            validators.DataRequired(message='密码不能为空.'),
                        ],
                        widget=widgets.PasswordInput(),
                        render_kw={
                            'class': 'loginuserpassword',
                            "placeholder": "请输入密码!"
                        })
    submit = SubmitField(label='登录', render_kw={"class": "loginbtn"})

    def validate_account(self, field):
        name = field.data
        user = User.query.filter_by(name=name).count()
        if user == 0:
            raise validators.ValidationError("用户名错误!")
コード例 #20
0
class LoginFrom(FlaskForm):
    """用户登录表单"""
    account = StringField(label='用户名',
                          validators=[
                              validators.DataRequired("请输入用户名!."),
                              validators.DataRequired(message='用户名不能为空.'),
                              validators.Length(min=4,
                                                message='用户名长度必须大于%(min)')
                          ],
                          widget=widgets.TextInput(),
                          render_kw={
                              'class': 'loginusername',
                              "placeholder": "请输入用户名!"
                          })
    pwd = PasswordField(
        label='密码',
        validators=[
            validators.DataRequired("请输入密码!."),
            validators.DataRequired(message='密码不能为空.'),
            # validators.Length(min=8, message='用户名长度必须大于%(min)d'),
            # validators.Regexp(regex="^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[$@$!%*?&])[A-Za-z\d$@$!%*?&]{8,}",
            #                   message='密码至少8个字符,至少1个大写字母,1个小写字母,1个数字和1个特殊字符')
        ],
        widget=widgets.PasswordInput(),
        render_kw={
            'class': 'loginuserpassword',
            "placeholder": "请输入密码!"
        })
    submit = SubmitField(label='登录', render_kw={"class": "loginbtn"})

    def validate_account(self, field):
        name = field.data
        user = User.query.filter_by(name=name).count()
        if user == 0:
            raise validators.ValidationError("用户名错误!")
コード例 #21
0
ファイル: app01.py プロジェクト: 292887172/7topmeeting
class LoginForm(Form):
    user = simple.StringField(label='用户名',
                              validators=[
                                  validators.DataRequired(message='用户名不能为空.'),
                                  validators.Length(
                                      min=2,
                                      max=18,
                                      message='用户名长度必须大于%(min)d且小于%(max)d')
                              ],
                              widget=widgets.TextInput(),
                              render_kw={
                                  'class': 'form-control',
                                  'placeholder': '用户名'
                              })
    pwd = simple.PasswordField(
        label='密码',
        validators=[
            validators.DataRequired(message='密码不能为空.'),
            validators.Length(min=8, message='用户密码长度必须大于%(min)d'),
            # validators.Regexp(regex="^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[$@$!%*?&])[A-Za-z\d$@$!%*?&]{8,}",
            #                   message='密码至少8个字符,至少1个大写字母,1个小写字母,1个数字和1个特殊字符')
        ],
        widget=widgets.PasswordInput(),
        render_kw={
            'class': 'form-control',
            'placeholder': '密码'
        })
コード例 #22
0
ファイル: mindfirl.py プロジェクト: Mahinramezani/mindfirl
class LoginForm(Form):
    '''Form'''
    name = simple.StringField(
        label="Username",
        widget=widgets.TextInput(),
        validators=[
            validators.DataRequired(message="username cannot be empty"),
            validators.Length(
                max=20,
                min=5,
                message="The length of username should between 5 and 20")
        ],
        render_kw={"class": "form-control"})

    pwd = simple.PasswordField(
        label="password",
        validators=[
            validators.DataRequired(message="password cannot be empty"),
            validators.Length(
                max=30,
                min=5,
                message="The length of password should between 5 and 30"),
        ],
        widget=widgets.PasswordInput(),
        render_kw={"class": "form-control"})
コード例 #23
0
class PasswordFieldNonHide(StringField):
    """
    A StringField, except renders an ``<input type="password">``.
    Also, whatever value is accepted by this field is not rendered back
    to the browser like normal fields.
    """
    widget = widgets.PasswordInput(hide_value=False)
コード例 #24
0
class LoginForm(FlaskForm):
    email = StringField(
        "Email",
        validators=[DataRequired(), Email()],
        widget=widgets.TextInput(),
        render_kw={
            "class": "form-control",
            "placeholder": "Enter email",
            "required": "",
            "autofocus": "",
        },
    )
    password = PasswordField(
        "Password",
        validators=[DataRequired()],
        widget=widgets.PasswordInput(),
        render_kw={
            "class": "form-control",
            "placeholder": "Password",
            "required": "",
            "autofocus": "",
        },
    )
    captcha = StringField(
        "CAPTCHA",
        validators=[DataRequired()],
        render_kw={
            "class": "form-control",
            "placeholder": "CAPTCHA",
            "required": "",
            "autofocus": "",
        },
    )
    submit = SubmitField("Login")
コード例 #25
0
class LoginForm(FlaskForm):
    email = StringField(
        "用户邮箱",
        validators=[DataRequired(), Email()],
        widget=widgets.TextInput(),
        render_kw={
            "class": "form-control",
            "placeholder": "请输入用户邮箱",
            "required": "",
            "autofocus": "",
        },
    )
    password = PasswordField(
        "密码",
        validators=[DataRequired()],
        widget=widgets.PasswordInput(),
        render_kw={
            "class": "form-control",
            "placeholder": "请输入密码",
            "required": "",
            "autofocus": "",
        },
    )
    captcha = StringField(
        "验证码",
        validators=[DataRequired()],
        render_kw={
            "class": "form-control",
            "placeholder": "请输入验证码",
            "required": "",
            "autofocus": "",
        },
    )
    submit = SubmitField("登陆")
コード例 #26
0
ファイル: forms.py プロジェクト: Chennl/workblog
class RegistrationForm(FlaskForm):
    username = StringField(
        label =u'用户名',
        validators = [
        validators.DataRequired(message='用户名不能为空'),
        validators.length(min=4, max=16, message='用户名长度必须大于%(min)d且小于%(max)d')]
    )
    nickname = StringField(
        label =u'昵称',
        validators = [
        validators.DataRequired(message='昵称不能为空'),
        validators.length(min=4, max=32, message='昵称长度必须大于%(min)d且小于%(max)d')]
        )
    email = StringField(label='电子邮箱', 
        validators=[
            validators.DataRequired(message='邮箱不能为空.'),
            validators.Email(message='邮箱格式错误')
         ],
        widget=widgets.TextInput(input_type='email'),
        render_kw={'class': 'form-control'}
    )

    password = PasswordField(
        label=u'密码',
        validators=[
        validators.DataRequired(message=u'密码不能为空'),
        validators.length(min=6, message=u'密码必须大于%(min)d位')
        ],
        widget=widgets.PasswordInput())

    password2 = PasswordField(
        label=u'重复密码',
        validators=[
            validators.DataRequired(message=u'重复密码不能为空.'),
            validators.EqualTo('password',message=u'两次密码不一致')
        ]
        )
   
    gender = fields.RadioField(
        label=u'性别',
        choices=(
            (1,u'男'),
            (0,u'女'),
        ),
        coerce=int,  #限制是int类型的
        render_kw={'class': 'form-control'}
    )

    submit = SubmitField(u'注册')

    def validate_username(self, username):
        user = User.query.filter_by(username=username.data).first()
        if user is not None:
            raise ValidationError('该用户名已经被注册!')

    def validate_email(self, email):
        user = User.query.filter_by(email=email.data).first()
        if user is not None:
            raise ValidationError('该邮箱已经被注册.')
コード例 #27
0
    class PasswordField(StringField):
        """
        Original source: https://github.com/wtforms/wtforms/blob/2.0.2/wtforms/fields/simple.py#L35-L42

        A StringField, except renders an ``<input type="password">``.
        Also, whatever value is accepted by this field is not rendered back
        to the browser like normal fields.
        """
        widget = widgets.PasswordInput(hide_value=False)
コード例 #28
0
class ProfileEditForm(Form):
    """Form for modifying profile info"""
    display_name = StringField(label='Display Name to be shown after login:'******'Your Full Name:')
    svn_username = StringField(
        label='Your SVN Username: (Do not enter credentials unless needed)')
    svn_password = PasswordField(
        label='Your SVN Password: (Do not enter credentials unless needed)',
        widget=widgets.PasswordInput(hide_value=False))
コード例 #29
0
ファイル: form_model.py プロジェクト: peindunk/hardcore_tv
class RegisteForm(FlaskForm):
    uname = StringField('用户名',validators=[DataRequired(),Length(1,8)])
    upwd1 = StringField('密码',
                        validators=[DataRequired()],
                        widget=widgets.PasswordInput())
    upwd2 = StringField('确认密码',
                        validators=[DataRequired(),EqualTo('upwd1','密码不一致')],
                        widget=widgets.PasswordInput())
    age = IntegerField('年龄',validators=[DataRequired(),NumberRange(1,150)])
    email = StringField('邮箱',validators=[DataRequired(),Email()])

    sex = RadioField('性别',
                     choices=[('男','男'),('女','女'),('保密','保密')],
                     validators=[DataRequired()])
    phone = StringField('手机',validators=[DataRequired(),Length(11,12)])
    city = StringField('城市',validators=[DataRequired(),Length(1,10)])
    ps = TextAreaField('签名')
    submit = SubmitField('注册')
コード例 #30
0
class GeneratePasswordForm(BaseSecureForm):
    """CSRF-protected form to generate a random password"""
    password = wtforms.PasswordField(
        _(u'Your password'),
        validators=[
            validators.InputRequired(message=_(u'A password is required')),
            validators.Length(min=6, message=_(u'Password must be more than 6 characters'))
        ],
        widget=widgets.PasswordInput())