def post(self): self.reset() name = self.request.get("username") u = User.get_by("name", name) if not u: self.userData.set_false() else: pw = self.request.get("password") if not u.check_password(pw): self.passData.set_false() if not self.userData.isValid or not self.passData.isValid: self.renderPage() else: self.login(u) self.redirect("/")
def post(self): self.resetErrors() rawName = self.request.get("username") if rawName and User.get_by(property_name = "name", value = rawName): self.userData.set_false() self.userData.errorMsg = "Username already taken" else: self.userData.is_valid(rawName) #logging.info("username is: %s", self.userError) rawPassword = self.request.get("password") rawVerify = self.request.get("verify") passwordsMatch = rawPassword == rawVerify if rawPassword and passwordsMatch: self.passData.is_valid(rawPassword) else: self.passData.set_false() self.passData.errorMsg = "Passwords do not match" #logging.info("password is: %s", self.passwordError) rawEmail = self.request.get("email") if rawEmail: self.emailData.is_valid(rawEmail) #logging.info("email is: %s", self.emailError) if not self.userData.isValid or not self.passData.isValid or not self.emailData.isValid: #logging.info("somethings gone wrong! userData:"+str(self.userData.isValid)+" passData: "+str(self.passData.isValid)+" emailData: "+str(self.emailData.isValid)) self.renderSignup() else: #logging.info("it worked!") newUser = User.generate_new(rawName, rawPassword, rawEmail) newUser.put() self.login(newUser) self.redirect("/")