自定义表格Flask安全注册

时间:2016-09-08 18:34:48

标签: python flask-security

我正在关注烧瓶安全自定义视图的官方文档 https://pythonhosted.org/Flask-Security/customizing.html

我已经延长了表格

@Override
public void onRequestPermissionsResult(int requestCode,
                                       String permissions[], int[] grantResults) {
    switch (requestCode) {
        case 1: {
          if (grantResults.length > 0
                    && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                // permission was granted!        
            } else {

                // permission denied!
                Toast.makeText(MainActivity.this, "Permission denied to write External storage", Toast.LENGTH_SHORT).show();
            }
            return;
        }
    }
}

这是我的用户类

class ExtendedRegisterForm(RegisterForm):
    first_name = StringField('First Name', [Required()])
    last_name = StringField('Last Name', [Required()])
security = Security(app, user_datastore, register_form=ExtendedRegisterForm)

但渲染视图会给我一个jinja模板错误

class User(db.Document, UserMixin):
    email = db.StringField(max_length=255, unique=True)
    password = db.StringField(max_length=255)
    first_name = db.StringField(max_length=255)
    last_name = db.StringField(max_length=255)
    active = db.BooleanField(default=True)
    confirmed_at = db.DateTimeField()
    last_login_at = db.DateTimeField()
    current_login_at = db.DateTimeField()
    last_login_ip = db.StringField(max_length=40)
    current_login_ip = db.StringField(max_length=40)
    login_count = db.IntField()

    roles = db.ListField(db.ReferenceField(Role), default=[])

UndefinedError:'flask_security.forms.ConfirmRegisterForm object'没有属性'first_name'

我错过了什么?

0 个答案:

没有答案