Example #1
0
    def validate_username(self, username):
        if re.search(NON_ALPHANUMERIC_RE, username):
            raise ma.ValidationError('Username should only contain letters, numbers '
                                     'and/or the underscore character.')

        existing = self.user_manager.get_by(username=username)
        if existing and (self.is_create() or existing != self.instance):
            raise ma.ValidationError('Sorry, that username is already taken.')
 def validate_email(self, email):
     existing = self.user_manager.get_by(email=email)
     if existing and (self.is_create() or existing != self.instance):
         raise ma.ValidationError('Sorry, that email is already taken.')
 def validate_email(self, email):
     existing = self.user_manager.get_by(email=email)
     if existing and (self.is_create() or existing != self.instance):
         raise ma.ValidationError(
             _('flask_unchained.bundles.security:error.email_already_associated',
               email=email))