示例#1
0
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)
示例#2
0
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)
示例#3
0
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)