def verify_csrf(self, request): a = request.get("query", {}) csrf_token_a = a.get("csrfmiddlewaretoken") csrf_token_b = webapp.get_cookie(request, "csrftoken") if csrf_token_a != csrf_token_b or not csrf_token_b: return False return True
def selected_lang(self): """ Return the currently selected language in the cookie If no language is selected in the cookie return the default language for the session """ return webapp.get_cookie(self.request, "lang", self.ses.locale.lang)
def selected_theme(self): """ Return the currently selected theme in the cookie If no theme is selected in the cookie return the default theme for the session """ return webapp.get_cookie(self.request, "theme", self.ses.theme)
def csrf_token(self): return webapp.get_cookie(self.request, "csrftoken", "")