def login(self, username=None, password=None, csrf_token=None): if cherrypy.request.method == 'GET': return template.render(login_error = False, csrftoken = form.register("login", cherrypy.session, cherrypy.request)) elif cherrypy.request.method == 'POST': if form.verify("login", csrf_token, cherrypy.session) == False: raise cherrypy.HTTPError(status=500, message='Detected an attempt of a cross site request forgery attack') if auth.login(username, password, cherrypy.session) == True: url = cherrypy.session.get('login_url') if url == None: url = "/" raise cherrypy.HTTPRedirect(url) return template.render(login_error = True, csrftoken = form.register("login", cherrypy.session, cherrypy.request))
def index(self): return template.render()