def login(self, request): CSRF.setToken(request) with open("loginpage.html") as f: loginPage = f.read() return TextResponse(loginPage)
def login_POST(self, request): if CSRF.checkToken(request): authCookie = yield self.db.checkAuth(request.args["user"], request.args["password"]) if authCookie: request.setCookie("SESSION", authCookie) defer.returnValue(Redirect()) else: response = TextResponse(u"login failed") response.setCode(400) defer.returnValue(response) else: response = TextResponse(u"CSRF failed") response.setCode(400) defer.returnValue(response)