Пример #1
0
def doLogout(req):
    cookie = PoorSession(req)
    if not "id" in cookie.data:
        req.log_error("Login cookie not found.", LOG_INFO)
        return
    
    cookie.destroy()
    cookie.header(req, req.headers_out)
    req.log_error("Login cookie was be destroyed (Logout)", LOG_INFO)
Пример #2
0
def checkLogin(req, redirectUri = None):
    cookie = PoorSession(req)
    if not "id" in cookie.data:
        req.log_error("Login cookie not found.", LOG_INFO)
        if redirectUri:
            redirect(req, redirectUri)
        return None

    if "ip" in cookie.data and cookie.data["ip"] != req.get_remote_host():
        cookie.destroy()
        cookie.header(req, req.headers_out)
        req.log_error("Login cookie was be destroyed (invalid IP address)",
                LOG_INFO)
        if redirectUri:
            redirect(req, redirectUri)
        return None

    return cookie
Пример #3
0
def doLogin(req, id, ip=None):
    cookie = PoorSession(req)
    cookie.data["id"] = id
    cookie.data["timestamp"] = int(time())
    if ip:
        cookie.data["ip"] = req.get_remote_host()
    cookie.header(req, req.headers_out)
    req.log_error("Login cookie was be set.", LOG_INFO)
Пример #4
0
def doLogin(req, id, ip = None):
    cookie = PoorSession(req)
    cookie.data["id"] = id
    cookie.data["timestamp"] = int(time())
    if ip:
        cookie.data["ip"] = req.get_remote_host()
    cookie.header(req, req.headers_out)
    req.log_error("Login cookie was be set.", LOG_INFO)
Пример #5
0
def doLogout(req):
    cookie = PoorSession(req)
    if not "id" in cookie.data:
        req.log_error("Login cookie not found.", LOG_INFO)
        return

    cookie.destroy()
    cookie.header(req, req.headers_out)
    req.log_error("Login cookie was be destroyed (Logout)", LOG_INFO)
Пример #6
0
def checkLogin(req, redirectUri=None):
    cookie = PoorSession(req)
    if not "id" in cookie.data:
        req.log_error("Login cookie not found.", LOG_INFO)
        if redirectUri:
            redirect(req, redirectUri)
        return None

    if "ip" in cookie.data and cookie.data["ip"] != req.get_remote_host():
        cookie.destroy()
        cookie.header(req, req.headers_out)
        req.log_error("Login cookie was be destroyed (invalid IP address)",
                      LOG_INFO)
        if redirectUri:
            redirect(req, redirectUri)
        return None

    return cookie