def verify_token(self, token):
        if not isinstance(token, six.string_types):
            raise AuthyException('Token to validate should be a string.')

        if not token.isdigit():
            raise AuthyException('Token has invalid format.')

        authy_id = int(self.user.authyprofile.authy_id)

        verification = self.client.tokens.verify(
            authy_id, str(token), {'force': self.force_verification})

        if verification.ok():
            return True

        self.errors = verification.errors()

        return False
    def register_user(self, cellphone):
        authy_user = self.client.users.create(self.user.username,
                                              int(cellphone.national_number),
                                              int(cellphone.country_code))

        if authy_user.ok():
            return self.make_authy_profile(cellphone, authy_user.id)

        errors = authy_user.errors()
        msg = 'Could not register Authy user: %s' % errors
        raise AuthyException(msg)
示例#3
0
 def side_effect(user_id, message):
     if message == '':
         raise AuthyException()