Пример #1
0
 def send_confirmation_email_fix(email):
     token = generate_confirmation_token(email)
     confirm_url = 'https://mathseminars.org/' + url_for(".confirm_email",
                                                         token=token)
     html = render_template("confirm_email.html", confirm_url=confirm_url)
     subject = "Please confirm your email"
     send_email(email, subject, html)
Пример #2
0
 def send_reset_password_fix(email):
     token = generate_password_token(email)
     reset_url = 'https://mathseminars.org/' + url_for(
         ".reset_password_wtoken", token=token)
     html = render_template("reset_password_email.html",
                            reset_url=reset_url)
     subject = "Resetting password"
     send_email(email, subject, html)
Пример #3
0
def send_reset_password(email):
    token = generate_password_token(email)
    reset_url = url_for(".reset_password_wtoken",
                        token=token,
                        _external=True,
                        _scheme="https")
    html = render_template("reset_password_email.html", reset_url=reset_url)
    subject = "Resetting password"
    send_email(email, subject, html)
Пример #4
0
def send_confirmation_email(email):
    token = generate_confirmation_token(email)
    confirm_url = url_for('.confirm_email',
                          token=token,
                          _external=True,
                          _scheme='https')
    html = render_template('confirm_email.html', confirm_url=confirm_url)
    subject = "Please confirm your email"
    send_email(email, subject, html)
Пример #5
0
def send_confirmation_email(email):
    token = generate_confirmation_token(email)
    confirm_url = url_for(".confirm_email", token=token, _external=True, _scheme="https")
    html = render_template("confirm_email.html", confirm_url=confirm_url)
    subject = "Please confirm your email"
    try:
        send_email(email, subject, html)
        return True
    except:
        import sys

        flash_error(
            'Unable to send email confirmation link, please contact <a href="mailto:[email protected]">[email protected]</a> directly to confirm your email'
        )
        app.logger.error("%s unable to send email to %s due to error: %s" % (timestamp(), email, sys.exc_info()[0]))
        return False
Пример #6
0
def get_endorsing_link():
    email = request.form["email"].strip()
    try:
        email = validate_email(email)["email"]
    except EmailNotValidError as e:
        flash_error("""Oops, email '%s' is not allowed. %s""", email, str(e))
        return redirect(url_for(".info"))
    rec = userdb.lookup(email, ["name", "creator", "email_confirmed"])
    if rec is None or not rec["email_confirmed"]:  # No account or email unconfirmed
        if db.preendorsed_users.count({'email':email}):
            endorsing_link = "<p>{0} has already been pre-endorsed.</p>".format(email)
        else:
            db.preendorsed_users.insert_many([{"email": email, "endorser": current_user._uid}])
            to_send = """Hello,

    I am offering you permission to add content (e.g., create a seminar)
    on the {topdomain} website.

    To accept this invitation:

    1. Register at {register} using this email address.

    2. Click on the link the system emails you, to confirm your email address.

    3. Now any content you create will be publicly viewable.


    Best,
    {name}
    """.format(
                name = current_user.name,
                topdomain = topdomain(),
                register = url_for('.register', _external=True, _scheme='https'),
            )
            data = {
                "body": to_send,
                "subject": "An invitation to collaborate on " + topdomain(),
            }
            endorsing_link = """
    <p>
    When {email} registers and confirms their email they will be able to create content.</br>
    <button onClick="window.open('mailto:{email}?{msg}')">
    Send email
    </button> to let them know.
    </p>
    """.format(
                email=email, msg=urlencode(data, quote_via=quote)
            )
    else:
        target_name = rec["name"]
        if rec["creator"]:
            endorsing_link = "<p>{target_name} is already able to create content.</p>".format(target_name=target_name)
        else:
            welcome = "Hello" if not target_name else ("Dear " + target_name)
            to_send = """{welcome},<br>
<p>
You have been endorsed you on {topdomain} and any content you create will
be publicly viewable.
</p>
<p>
Thanks for using {topdomain}!
</p>

""".format(
                welcome = welcome,
                topdomain = topdomain()
            )
            subject = "Endorsement to create content on " + topdomain()
            send_email(email, subject, to_send)
            userdb.make_creator(email, int(current_user.id))
            endorsing_link = "<p>{target_name} is now able to create content.</p> ".format(
                target_name=target_name if target_name else email
            )
    session["endorsing link"] = endorsing_link
    return redirect(url_for(".info"))