Example #1
0
class ExtRegisterForm(RegisterForm):
    full_name = StringField('Name', [Required()])
Example #2
0
class EmailForm(Form):
    subject = StringField('Asunto', [Required()])
    message = TextAreaField('Mensaje', [Required()])
    attachment = FileField('Adjunto')
Example #3
0
 class MyLoginForm(LoginForm):
     email = StringField('My Login Email Address Field')
Example #4
0
 class MyForgotPasswordForm(ForgotPasswordForm):
     email = StringField(
         'My Forgot Email Address Field',
         validators=[email_required, email_validator, valid_user_email])
Example #5
0
 class MyRegisterForm(ConfirmRegisterForm):
     email = StringField("My Register Email Address Field")
Example #6
0
 class MySendConfirmationForm(SendConfirmationForm):
     email = StringField('My Send Confirmation Email Address Field')
Example #7
0
class ExtendedRegisterForm(RegisterForm):
    """
    Adds first name and captcha to the registration form
    """
    first_name = StringField(_("First name"), [DataRequired()])
    recaptcha = RecaptchaField("Captcha")
Example #8
0
 class MyLoginForm(LoginForm):
     fixed_length = StringField(
         "FixedLength", validators=[DataRequired(), Length(3, 3)]
     )
Example #9
0
class ConfirmRegisterForm(Form, RegisterFormMixin):
    """customized ConfirmRegisterForm

    Attributes:
        address (str): Description
        career (str): Description
        email (str): Description
        nickname (str): Description
        over18 (bool): Description
        password (str): Description
        realname (str): Description
        username (str): Description
    """

    user_id = StringField(
        get_form_field_label("username"),
        validators=[],
    )

    username = StringField(
        get_form_field_label("username"),
        validators=[],
    )

    password = PasswordField(get_form_field_label("password"),
                             validators=[validators.Optional()])

    email = StringField(get_form_field_label("email"),
                        validators=[validators.Optional()])

    nickname = StringField(get_form_field_label("nickname"),
                           validators=[validators.Optional()])

    realname = StringField(get_form_field_label("realname"),
                           validators=[validators.Optional()])

    career = StringField(get_form_field_label("career"),
                         validators=[validators.Optional()])

    address = StringField(get_form_field_label("address"),
                          validators=[validators.Optional()])

    over18 = BooleanField(get_form_field_label("over18"),
                          validators=[validators.Optional()])

    jwt = StringField(
        get_form_field_label("jwt"),
        validators=[],
    )

    def validate(self):
        """Summary

        Returns:
            TYPE: Description
        """
        if not super(ConfirmRegisterForm, self).validate():
            return False

        # XXX hack with user_id data
        if not self.user_id.data and self.username.data:
            self.user_id.data = self.username.data

        # To support unified sign in - we permit registering with no password.
        if not config_value("UNIFIED_SIGNIN"):
            # password required
            if not self.password.data or not self.password.data.strip():
                self.password.errors.append(
                    get_message("PASSWORD_NOT_PROVIDED")[0])
                return False

        if not self.password.data:
            return False

        if self.password.data:
            # We do explicit validation here for passwords
            # (rather than write a validator class) for 2 reasons:
            # 1) We want to control which fields are passed -
            #    sometimes that's current_user
            #    other times it's the registration fields.
            # 2) We want to be able to return multiple error messages.

            rfields = {}
            for k, v in self.data.items():
                if hasattr(_datastore.user_model, k):
                    rfields[k] = v
            if 'password' in rfields:
                del rfields["password"]

            pbad = _security._password_validator(self.password.data, True,
                                                 **rfields)

            # validate with ptt-server

            user_id = self.user_id.data
            password = self.password.data

            email = self.email.data
            nickname = self.nickname.data
            realname = self.realname.data
            career = self.career.data
            address = self.address.data
            over18 = self.over18.data

            err, result = register_user(user_id, password, email, nickname,
                                        realname, career, address, over18)
            if err:
                self.user_id.errors = result
                return False

            self.jwt.data = result

        return True
Example #10
0
class ExtendedLoginForm(LoginForm):
    email = StringField(
        'Email/Username',
        validators=[Required(message='No account info has been input.')])
    password = PasswordField('Password', validators=[password_required])
Example #11
0
class ExtendedRegisterForm(RegisterForm):
    username = StringField('Username', [Required()])
Example #12
0
class ExtendedLoginForm(LoginForm):
    # This is basically a hack to make it easy to login with both email
    # username. This is then modified in the config file
    # https://stackoverflow.com/questions/30827696/flask-security-login-via-username-and-not-email
    email = StringField("Username or Email Address", [Required()])
Example #13
0
class ExtendedRegisterForm(RegisterForm):
    first_name = StringField('First Name', [Required()])
    last_name = StringField('Last Name', [Required()])
Example #14
0
class CustomRegisterForm(RegisterForm):
    username = StringField('Username', [Required()])
Example #15
0
class ExtendedLoginForm(LoginForm):
    email = StringField("邮箱/用户名", validators=[Required(message="未输入账号内容")])
    password = PasswordField("密码", validators=[password_required])
Example #16
0
class CustomLoginForm(LoginForm):
    email = StringField('Username or Email', [Required()])
Example #17
0
class ExtendedRegisterForm(RegisterForm):
    employer_name = StringField('Наименование работодателя', [Required()])
    employer_description = TextAreaField('Описание работодателя', [Required()])
Example #18
0
class ExtendedLoginForm(LoginForm):
    email = StringField('邮箱/用户名', validators=[Required(message='未输入账号内容')])
    password = PasswordField('密码', validators=[password_required])
Example #19
0
class AccountRegisterForm(Form):
    name = StringField('Account Name', [Required()])
    submit = SubmitField('Register via Contract')
Example #20
0
 class MyLoginForm(LoginForm):
     myfield = StringField("My Custom Field",
                           validators=[Required(message="hi")])
Example #21
0
class LoginForm(Form):
    name = StringField('Account Name', [Required()])
    submit = SubmitField('Login via Contract')
Example #22
0
 class MyPasswordlessLoginForm(PasswordlessLoginForm):
     email = StringField('My Passwordless Email Address Field')
 class MyRegisterForm(RegisterForm):
     additional_field = StringField("additional_field")
Example #24
0
 class MyRegisterForm(RegisterForm):
     email = StringField('My Register Email Address Field')
 class MyRegisterForm(ConfirmRegisterForm):
     username = StringField("Username")
Example #26
0
 class MyResetPasswordForm(ResetPasswordForm):
     password = StringField('My Reset Password Field')
Example #27
0
class ExtendedConfirmRegisterForm(ConfirmRegisterForm):
    username = StringField('username', [Required()])
Example #28
0
class FlaskrLoginForm(LoginForm):
    # Note: clumsily overrides the default label for Email,
    # because I can't resolve the lazystring from get_form_field_label at instantiation time
    email = StringField("Username or Email", validators=[email_required])
Example #29
0
from sqlalchemy import func
from beavy.app import db

# Define models
roles_users = db.Table(
    'roles_users',
    db.Column('user_id',
              db.Integer(),
              db.ForeignKey('user.id'),
              nullable=False),
    db.Column('role_id',
              db.Integer(),
              db.ForeignKey('role.id'),
              nullable=False))

RegisterForm.name = StringField('Full Name')
ConfirmRegisterForm.name = StringField('Full Name')


class User(db.Model, UserMixin):
    __LOOKUP_ATTRS__ = []
    id = db.Column(db.Integer, primary_key=True)
    created_at = db.Column('created_at',
                           db.DateTime(),
                           nullable=False,
                           server_default=func.now())
    email = db.Column(db.String(255), unique=True, nullable=False)
    name = db.Column(db.String(255))
    password = db.Column(db.String(255))
    active = db.Column(db.Boolean())
    confirmed_at = db.Column(db.DateTime())