def delete_feed(ID): try: userEmail = get_jwt_identity() token = request.headers['Authorization'].replace('Bearer ', '') tempUser = check_token(token, userEmail) if tempUser is None: return make_response({"error": "Forbidden"}, 403) else: tempFeed = Feed.objects.get(id=ID) tempFeed.delete() return make_response({"deleted": "true"}, 200) except: return make_response({"error": "Bad Request"}, 400)
def logout_user(): try: userEmail = get_jwt_identity() token = request.headers['Authorization'].replace('Bearer ', '') tempUser = check_token(token, userEmail) if tempUser is None: return make_response({"error": "Forbidden"}, 403) else: tempUser.token.remove(token) tempUser.save() return make_response({"completed": "true"}, 200) except: return make_response({"error": "Bad Request"}, 400)
def post_feed(): try: userEmail = get_jwt_identity() token = request.headers['Authorization'].replace('Bearer ', '') tempUser = check_token(token, userEmail) if tempUser is None: return make_response({"error": "Forbidden"}, 403) else: body = request.get_json() tempFeed = Feed(**body) tempFeed.save() return make_response({"completed": "true"}, 200) except: return make_response({"error": "Bad Request"}, 400)