def post(self): user_username = self.request.get('username') user_password = self.request.get('password') user_verify = self.request.get('verify') user_email = self.request.get('email') venmo_email = self.request.get('venmo_email') bio = self.request.get('bio') username = validation.username(user_username) password = validation.password(user_password) verify = validation.verify(user_verify, user_password) email = validation.edu_email(user_email) venmo_email_verify = validation.email(venmo_email) userError="" passError="" verifyError="" emailError="" venmoEmailError = "" if not username: userError = "That's not a valid username." user_username="" if not password: passError = "That wasn't a valid password." if not verify: verifyError = "Your passwords didn't match." if not email: emailError = "That's not a valid email." user_email="" if venmo_email != "" and venmo_email_verify is None: venmoEmailError = "That's not a valid email. Leave empty if you don't have one" venmo_email="" if username and password and verify and email and (venmoEmailError == ""): passHash = validation.make_pw_hash(username, password) code = validation.make_salt() user = User(username = username, passHash=passHash, email=email, bio=bio, venmo_email=venmo_email, activationCode=code) u = User.all().filter('username ='******'Content-Type'] = 'text/plain' cookie_val = validation.make_secure_val(str(user_id)) self.response.headers.add_header('Set-Cookie',str('user=%s; Path=/' % cookie_val)) self.sendActivationEmail(email, code) self.redirect("/home") else: self.write_form(userError, passError, verifyError, emailError, venmoEmailError, user_username, user_email, bio=bio)
def post(self): user = User.get_by_id(self.getUser()) if "updatePassword" in self.request.POST: password_success, password_error = "", "" if validation.valid_pw(user.username, self.request.get('currentPassword'), user.passHash): new_pass = self.request.get('new_password') if new_pass == self.request.get('verifyNewPassword'): user.passHash = validation.make_pw_hash( user.username, new_pass) user.put() password_success = "Password Changed Successfully!" else: password_error = "New passwords are not the same" else: password_error = "That is not your current password" self.render('admin.html', user=user, update_error=password_error, update_success=password_success) elif "otherChanges" in self.request.POST: user_email = self.request.get('email') venmo_email = self.request.get('venmo_email') email = validation.edu_email(user_email) venmo_email_verify = validation.email(venmo_email) email_error, venmo_email_error, update_success, update_error = "", "", "", "" if not email: email_error = "That's not a valid email." user_email = "" if venmo_email != "" and venmo_email_verify is None: venmo_email_error = "Invalid email. This is an optional field." venmo_email = "" if email and (venmo_email_error == ""): try: user.email = user_email user.venmo_email = venmo_email user.bio = self.request.get('bio') user.put() update_success = "Succesfully Updated!" except: update_error = "Could not save changes :(" self.render('admin.html', user=user, update_success=update_success, update_error=update_error, email_error=email_error, venmo_email_error=venmo_email_error)