Пример #1
0
    def delete(self):
        session = Session()
        # result = session.query(User).filter_by(id=user_id).first()
        exist = auth.current_user()
        if exist:
            print("User has been deleted")
        if not exist:
            abort(500, message="User doesn't exist, cannot delete")

        exist = session.merge(exist)
        session.delete(exist)
        session.commit()
        return "User deleted", 204
Пример #2
0
    def put(self):
        session = Session()
        args = user_update_args.parse_args()
        # result = session.query(User).filter_by(id=user_id).first()
        exist = auth.current_user()
        if not exist:
            abort(404, message="User doesn't exist, cannot update")
        if args['username']:
            exist.username = args['username']
        if args['password']:
            exist.password = hash_password(args['password'])

        exist = session.merge(exist)
        session.add(exist)
        session.commit()

        return exist