示例#1
0
def get_notes():
    response = verify_login(request)
    if response:
        return response
    message = request.cookies.get("message")
    key = request.cookies.get("session_key")
    session = storage.get_session(key)
    response = make_response(
        render_template("notes.html", message=message, session=session))
    storage.update_session(key, {"pages": (session.get("pages", 0) + 1)})
    response.set_cookie("session_key", key, max_age=600)
    response.set_cookie("message", "", expires=0)
    return response
示例#2
0
def get_notes():
    message = request.cookies.get("message")
    key = request.cookies.get("session_key")
    # create a rejection response
    response = make_response(redirect("/login"))
    response.set_cookie("session_key", "", expires=0)
    if not key:
        response.set_cookie("message", "User is not logged in.")
        return response
    session = storage.get_session(key)
    if not session:
        response.set_cookie("message", "User is not logged in.")
        return response
    response = make_response(
        render_template("notes.html", message=message, session=session))
    storage.update_session(key, {"pages": (session.get("pages", 0) + 1)})
    response.set_cookie("session_key", key, max_age=600)
    response.set_cookie("message", "", expires=0)
    return response
示例#3
0
def test_sessions():
    test_session = "session." + str(time.time())
    s = storage.get_session(test_session)
    assert s == None
    storage.add_session({'key': test_session})
    s = storage.get_session(test_session)
    assert type(s) is dict
    assert 'key' in s
    assert s['key'] == test_session
    storage.update_session(test_session, {'elephant': 12})
    s = storage.get_session(test_session)
    assert type(s) is dict
    assert 'key' in s
    assert s['key'] == test_session
    assert 'elephant' in s
    assert s['elephant'] == 12
    storage.delete_session(test_session)
    s = storage.get_session(test_session)
    assert s == None
def post_udashboard():
    #get session key from users cookie. Could be dangerous. BE CAREFUL!!
    key = request.cookies.get("session_key")

    #response used if checks fail
    response = make_response(redirect("/login"))
    response.set_cookie("session_key", "", expires=0)

    #check for key and session
    if not key:
        return response
    session = storage.get_session(key)
    if not session:
        return response

    #TODO: Something to look into: Might need to determine which button was clicked first

    #schedule/edit a call

    response = make_response(
        render_template("user_dashboard.html", session=session))
    storage.update_session(key)
    response.set_cookie("session_key", key, max_age=600)
    return response
def get_udashboard():
    key = request.cookies.get("session_key")

    #response used if checks fail
    response = make_response(redirect("/login"))
    response.set_cookie("session_key", "", expires=0)

    #check for key and session
    if not key:
        return response
    session = storage.get_session(key)
    if not session:
        return response

    #variable to display scheduled calls
    email = session['email']
    calls = storage.customer_scheduled_calls(email)

    #displaying page and updating session
    response = make_response(
        render_template("user_dashboard.html", session=session), calls)
    storage.update_session(key)
    response.set_cookie("session_key", key, max_age=600)
    return response
def get_pdashboard():
    #get session key from users cookie. Could be dangerous. BE CAREFUL!!
    key = request.cookies.get("session_key")

    #response used if checks fail
    response = make_response(redirect("/login"))
    response.set_cookie("session_key", "", expires=0)

    #check for key and session
    if not key:
        return response
    session = storage.get_session(key)
    if not session:
        return response

    #view scheduled calls
    email = session['email']
    calls = storage.provider_scheduled_calls(email)

    response = make_response(
        render_template("provider_dashboard.html", session=session), calls)
    storage.update_session(key)
    response.set_cookie("session_key", key, max_age=600)
    return response