added a small cherrypy logout page.
This commit is contained in:
parent
1e1ffa362e
commit
c87f7eed3e
1 changed files with 18 additions and 10 deletions
28
logout.py
28
logout.py
|
@ -1,13 +1,21 @@
|
|||
import database
|
||||
import login
|
||||
|
||||
def process_form(req,form):
|
||||
username = form["username"]
|
||||
myuser = database.Users.byUsername(username)
|
||||
myuser.sessionid = None
|
||||
|
||||
login.main(req,form)
|
||||
|
||||
from cherrypy import cpg
|
||||
from cherrypy.lib import httptools
|
||||
|
||||
def main(req,form):
|
||||
process_form(req,form)
|
||||
|
||||
class Logout:
|
||||
def index(self):
|
||||
try:
|
||||
username = cpg.request.sessionMap["username"]
|
||||
myuser = database.Users.byUsername(username)
|
||||
myuser.sessionid = None
|
||||
myuser.timeout = 0
|
||||
except:
|
||||
return helper.cs_render("templates/not_logged_in.cs")
|
||||
username = ""
|
||||
#sessionid = cpg.request.sessionMap["_sessionId"]
|
||||
# now let cookie expire
|
||||
cpg.response.simpleCookie["WebGoSessionCookie"]["expires"] = 0
|
||||
httptools.redirect("/")
|
||||
index.exposed = True
|
Loading…
Reference in a new issue