Пример #1
0
 def post(self, email, uid):
     # todo store and verify uid
     user = User.query.filter_by(username=email).first()
     if not user:
         user = User(username=email)
         user.set_password(uid)
         db.session.add(user)
         db.session.commit()
     token = user.generate_auth_token()
     return {'token': token.decode('ascii')}, 200
Пример #2
0
 def setUp(self):
     self.app = create_app('testing')
     self.ctx = self.app.app_context()
     self.ctx.push()
     db.drop_all()
     db.create_all()
     u = User(email=self.default_email,
              username=self.default_username,
              password=self.default_password)
     db.session.add(u)
     db.session.commit()
     # 默认使用token作为所有接口的验证方式
     self.client = TestClient(self.app, u.generate_auth_token(), '')