def start_validation(self, email): if not email or not db.is_valid_email_reset(email): self.redirect('/forgot_password?error=%s' % 'Invalid e-mail address') return code = str(uuid.uuid4()) self.send_validate_email(email, code) data = {'message': 'Enter your reset code:', 'email': email, 'activation': True} path = os.path.join(os.path.dirname(__file__), "templates/forgot_password.html") self.response.out.write(template.render(path, data))
def send_validate_email(self, email, code): profile = db.is_valid_email_reset(email) if profile: db.clean_previous_activation(email) validate = model.ValidateUser() validate.username = profile.login.username validate.email = email validate.validate_code = code validate.put() mailFrom = "*****@*****.**" subject = "Reset Account" body = "This is your reset code: %s" % code mail.send_mail(mailFrom, email, subject, body)