auth.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:JmilkFan-s-Blog 作者: JmilkFan 项目源码 文件源码
def post(self):
        """Can be execute when receive HTTP Method `POST`."""

        args = parsers.user_post_parser.parse_args()
        user = User.query.filter_by(username=args['username']).first()

        # Check the args['password'] whether as same as user.password.
        if user.check_password(args['password']):
            # serializer object will be saved the token period of time.
            serializer = Serializer(
                current_app.config['SECRET_KEY'],
                expires_in=600)
            return {'token': serializer.dumps({'id': user.id})}
        else:
            abort(401)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号