def __fetch_session():
    cookie = request.cookies.get('chatterbox')

    user = application_controller.current_user(cookie)

    if user:
        user_response = build_user_response_object(user)
        return jsonify(user=user_response)
    else:
        return jsonify(user={})
def __destroy_session():
    cookie = request.cookies.get('chatterbox')

    user = application_controller.current_user(cookie)

    application_controller.logout(cookie)

    response = jsonify(user=user, message="Goodbye {0}!".format(user.username))
    response.set_cookie('chatterbox', '', expires=0)

    return response