def validate(self):
        if not super(UsernameLoginForm, self).validate():
            pass
        if self.login.data.strip() == '':
            self.login.errors.append(get_message('LOGIN_NOT_PROVIDED')[0])
            return False

        if self.password.data.strip() == '':
            self.password.errors.append(get_message('PASSWORD_NOT_PROVIDED')[0])
            return False

        self.user = _datastore.find_user(login=self.login.data.strip())

        if self.user is None:
            self.login.errors.append(get_message('USER_DOES_NOT_EXIST')[0])
            return False
        if not self.user.password:
            self.password.errors.append(get_message('PASSWORD_NOT_SET')[0])
            return False
        if not verify_and_update_password(self.password.data, self.user):
            self.password.errors.append(get_message('INVALID_PASSWORD')[0])
            return False
        if requires_confirmation(self.user):
            self.login.errors.append(get_message('CONFIRMATION_REQUIRED')[0])
            return False
        if not self.user.is_active():
            self.login.errors.append(get_message('DISABLED_ACCOUNT')[0])
            return False
        return True
def unique_username(form, field):
    if _datastore.find_user(username=field.data) is not None:
        msg = get_message('EMAIL_ALREADY_ASSOCIATED', email=field.data)[0]
        raise ValidationError(msg)
Exemple #3
0
def unique_username(form, field):
    if _datastore.find_user(email=field.data) is not None:
        msg = "%s may already have an account" % field.data
        raise ValidationError(msg)
Exemple #4
0
def same_or_unique_username(form, field):
    if not form.existing_email.data == field.data:
        if _datastore.find_user(email=field.data) is not None:
            msg = "Sorry, you cannot change your email address to %s" % field.data
            raise ValidationError(msg)
Exemple #5
0
def unique_username(form, field):
    if _datastore.find_user(email=field.data) is not None:
        msg = "%s may already have an account" % field.data
        raise ValidationError(msg)
Exemple #6
0
def same_or_unique_username(form, field):
    if not form.existing_email.data == field.data:
        if _datastore.find_user(email=field.data) is not None:
            msg = "Sorry, you cannot change your email address to %s" % field.data
            raise ValidationError(msg)
def unique_username(form, field):
    if _datastore.find_user(username=field.data) is not None:
        msg = get_message('EMAIL_ALREADY_ASSOCIATED', email=field.data)[0]
        raise ValidationError(msg)