Exemplo n.º 1
0
    def signup():
        email = request.form["email"]
        if not email:
            error = "No email address provided."
            return render_template("error.html", error=error)

        # if no user with this email, we are good
        try:
            profile = Profile.query.filter(Profile.email==email).one()
            error = "A user already exists with this email address."
            return render_template("error.html", error=error)
        except:
            pass

        try:
            key = temp_auth(db, TempAuth, email) 
        except Exception as error:
            return render_template("error.html", error=error)

        # set as environment variable. use your own judgement.
        message = Message(
                app.config["SIGN_UP_MESSAGE"],
                sender=app.config["SIGN_UP_SENDER"],
                recipients = [email],
                )

        message.html = email_html(
                app,
                "sign-up",
                url_root = request.url_root,
                key = key,
                )

        mail.send(message)
        return render_template("auth/signup-thanks.html", email=email)
Exemplo n.º 2
0
    def password_reset():
        email = request.form["email"]
        print(email)
        if not email:
            error = "No email address provided."
            return render_template("error.html", error=error)

        # if no user with this email, we are good
        try:
            profile = Profile.query.filter(Profile.email==email).one()
        except Exception as error:
            #error = "No user with that email address."
            return render_template("error.html", error=error)

        try:
            key = temp_auth(db, TempAuth, email) 
        except Exception as error:
            return render_template("error.html", error=error)

        # set as environment variable. use your own judgement.
        message = Message(
                app.config["SIGN_UP_MESSAGE"],
                sender=app.config["SIGN_UP_SENDER"],
                recipients = [email],
                )

        # password-reset is also name of template, in case you are me
        message.html = email_html(
                app,
                "password-reset",
                url_root = request.url_root,
                key = key,
                )

        mail.send(message)
        return render_template("auth/signup-thanks.html", email=email)