Ejemplo n.º 1
0
def login_check():
    cookie = bottle.request.get_cookie("session")

    if not cookie:
        print("no cookie...")
    else:
        session_id = user.check_secure_val(cookie)
        if not session_id:
            print("no secure session_id")
        else:
            # look up username record
            db = blog_connection()
            print("Look up session id %s" % session_id)
            session = user.get_session(db, session_id)
            return session and session['username']
Ejemplo n.º 2
0
def process_logout():
    cookie = bottle.request.get_cookie("session")

    if not cookie:
        print("no cookie...")
        bottle.redirect("/signup")
    else:
        session_id = user.check_secure_val(cookie)
        if not session_id:
            print("no secure session_id")
            bottle.redirect("/signup")
        else:
            db = blog_connection()

            # remove the session
            user.end_session(db, session_id)
            print("clearing the cookie")
            bottle.response.set_cookie("session", "")
            bottle.redirect("/signup")