user.py 文件源码

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

项目:OpenManga-sync 作者: nv95 项目源码 文件源码
def put(self):
        try:
            args = parser.parse_args()
            pass_md5 = hashlib.md5(args['password'].encode('utf-8')).hexdigest()
            new_user = User(login=args['login'], password=pass_md5)
            db.session.add(new_user)
            new_token = Token(token=str(uuid.uuid4()), user=new_user, device=args['device'])
            if args['expires'] is not None:
                new_token.expires_at = datetime.fromtimestamp(args['expires'] / 1000.0)
            db.session.add(new_token)
            db.session.commit()
            return {'token': new_token.token}
        except Exception as e:
            db.session.rollback()
            log.error(e)
            return {'state': 'fail', 'message': str(e)}, 500

    # close session(remove token)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号