def forgotten_password(context: 'micro_context', email: str) -> dict: ''' emails your password to you ''' with context.session as session: person = session.query(model.Person).filter_by(email=email).first() if person is None: raise HTTPError( 400, reason="<strong>Failed</strong> Email not registered!") template_path = resource_filename('spddo.micro', "templates/email") html, body = generate_templates.generate(template_path, "forgotten.html", "forgotten.txt", email=person.email, password=person.password) result = send(person.email, "*****@*****.**", "welcome to spddo-chat", body, html) logging.info(result) return "email sent."
def register(context: 'micro_context', email: str, password: str) -> dict: ''' register your email and password to be able to login ''' with context.session as session: try: person = model.Person(email=email, password=password) session.add(person) session.commit() except IntegrityError: raise HTTPError( 400, reason="<strong>Failed</strong> Email already registered!") template_path = resource_filename('spddo.micro', "templates/email") html, body = generate_templates.generate(template_path, "registered.html", "registered.txt", email=person.email, password=person.password) result = send(person.email, "*****@*****.**", "welcome to spddo-chat", body, html) logging.info(result) return "an email has been sent to that address with your password."