def post(self): # Authenticate admin = AdminAuthenticate(self.request) username = self.request.get("username") password = self.request.get("password") # validate form if not username or not password: return self.redirect("/admin/login") adminFind = Admin.query().filter(Admin.name == username).get() if not adminFind: return self.redirect("/admin/login") adminFind = adminFind[0] pw_hash = adminFind.pw_hash # validate admin if not hashes.valid_pw(username, password, pw_hash): return self.redirect("/admin/login") # validation successful - set cookie headers admin_id = str(adminFind.key.id()) secure_val = hashes.make_secure_val(admin_id) self.response.headers.add_header( 'Set-Cookie', str('name_adm=%s; Path=/' % secure_val)) return self.redirect("/admin/home")
def post(self): # Authenticate admin = AdminAuthenticate(self.request) username = self.request.get("username") password = self.request.get("password") # validate form if not username or not password: return self.redirect("/admin/login") adminFind = Admin.query().filter(Admin.name==username).get() if not adminFind: return self.redirect("/admin/login") adminFind = adminFind[0] pw_hash = adminFind.pw_hash # validate admin if not hashes.valid_pw(username, password, pw_hash): return self.redirect("/admin/login") # validation successful - set cookie headers admin_id = str(adminFind.key.id()) secure_val = hashes.make_secure_val(admin_id) self.response.headers.add_header('Set-Cookie', str('name_adm=%s; Path=/' % secure_val)) return self.redirect("/admin/home")
def SetLoginCookies(request, user): user_id = str(user.key.id()) secure_val = hashes.make_secure_val(user_id) request.response.headers.add_header('Set-Cookie', str("name=%s; Path=/" % secure_val))