示例#1
0
 def test_publicid(self):
     p = PublicId(idtype=PublicId.TWITTER, account="user1", user_id=self.user.id, verifyed=True)
     db.session.add(p)
     db.session.commit()
     p = PublicId(idtype=PublicId.EMAIL, account="user1", user_id=self.user.id, verifyed=True, code="my_code")
     db.session.add(p)
     db.session.commit()
     old_code = p.code
     p.refresh_code()
     assert p.code != old_code
示例#2
0
def twitter_verify(self, code, twitter_id=None, username=None, paid=False):
    verify = TwitterVerify()
    try:
        if verify.twitter_verify(code, twitter_id, username, paid):
            PublicId.get(account=username, idtype=PublicId.TWITTER).accept_verify()
            return True
        else:
            raise Exception("Message doesn't found")
    except Exception as exc:
        raise self.retry(countdown=20, exc=exc)
示例#3
0
 def test_verify_email(self):
     p = PublicId(idtype=PublicId.EMAIL, account="*****@*****.**", user_id=self.user.id)
     db.session.add(p)
     db.session.commit()
     p.refresh_code()
     url = '/api/verify?key={}'.format(p.code)
     result = self.client.get(url)
     self.assertEqual(result.status_code, 200)
     data = json.loads(result.data.decode('ascii'))
     assert data["message"] == "verify completed"
     assert p.verifyed
示例#4
0
    def post():
        username = request.form.get("username")
        service = request.form.get("service")
        p = PublicId.get(idtype=service, account=username).refresh_code()

        twitter_verify.apply_async(kwargs=({"code": p.code, "username": username}), countdown=5)
        return Response(
            json.dumps({"text": VERIFY.format(p.code)}, default=json_serial), status=200, mimetype="application/json"
        )