예제 #1
0
def process_logout():

    connection = pymongo.Connection(connection_string, safe=True)

    cookie = bottle.request.get_cookie("session")

    if (cookie == None):
        print "no cookie..."
        bottle.redirect("/signup")

    else:
        session_id = user.check_secure_val(cookie)

        if (session_id == None):
            print "no secure session_id"
            bottle.redirect("/signup")
            
        else:
            # remove the session

            user.end_session(connection, session_id)

            print "clearing the cookie"

            bottle.response.set_cookie("session","")


            bottle.redirect("/signup")
예제 #2
0
파일: app.py 프로젝트: reterVision/office
def signout():
    cookie = request.cookies.get(COOKIE, None)
    session["logged_in"] = False
    session["username"] = None

    if cookie is None:
        return redirect_back("signin")
    else:
        session_id = user.check_secure_val(cookie)

        if session_id is None:
            return redirect_back("signin")
        else:
            connection = pymongo.Connection(CONNECTION_STRING,
                                            safe=True)
            user.end_session(connection[DATABASE], session_id)
            redirect_to_signin = redirect_back("signin")
            response = app.make_response(redirect_to_signin)
            response.set_cookie(COOKIE, value="")
            return response
예제 #3
0
def login_check():
    connection = pymongo.Connection(connection_string, safe=True)
    cookie = bottle.request.get_cookie("session")

    if (cookie == None):
        print "no cookie..."
        return None

    else:
        session_id = user.check_secure_val(cookie)

        if (session_id == None):
            print "no secure session_id"
            return None
            
        else:
            # look up username record
            session = user.get_session(connection, session_id)
            if (session == None):
                return None

    return session['username']