コード例 #1
0
ファイル: email.py プロジェクト: tquentin/dnstwister
def email_subscribe_pending_confirm(hexdomain):
    """Send a confirmation email for a user."""
    domain = tools.parse_domain(hexdomain)
    if domain is None:
        flask.abort(
            400,
            'Malformed domain or domain not represented in hexadecimal format.'
        )

    hide_noisy = bool(flask.request.form.get('hide_noisy'))

    email_address = flask.request.form['email_address']

    if email_address.strip() == '':
        return flask.redirect('/email/subscribe/{}/0?hide_noisy={}'.format(
            hexdomain, hide_noisy))

    verify_code = tools.random_id()
    verify_url = flask.request.url_root + 'email/verify/{}'.format(verify_code)
    email_body = email_tools.render_email('confirm.html',
                                          domain=domain,
                                          verify_url=verify_url)

    repository.propose_subscription(verify_code, email_address, domain,
                                    hide_noisy)

    emailer.send(email_address, 'Please verify your subscription', email_body)

    return flask.render_template('www/email/pending_verify.html',
                                 domain=domain)
コード例 #2
0
ファイル: email.py プロジェクト: peterwallhead/dnstwister
def email_subscribe_pending_confirm(hexdomain):
    """Send a confirmation email for a user."""
    domain = tools.parse_domain(hexdomain)
    if domain is None:
        flask.abort(400, 'Malformed domain or domain not represented in hexadecimal format.')

    email_address = flask.request.form['email_address']

    if email_address.strip() == '':
        return flask.redirect('/email/subscribe/{}/0'.format(hexdomain))

    verify_code = tools.random_id()
    verify_url = flask.request.url_root + 'email/verify/{}'.format(verify_code)
    email_body = email_tools.render_email(
        'confirm.html',
        domain=domain,
        verify_url=verify_url
    )

    repository.propose_subscription(verify_code, email_address, domain)
    emailer.send(
        email_address, 'Please verify your subscription', email_body
    )

    return flask.render_template('www/email/pending_verify.html', domain=domain)
コード例 #3
0
ファイル: email.py プロジェクト: peterwallhead/dnstwister
def email_subscribe_confirm_email(verify_code):
    """Handle email verification."""
    pending_verify = repository.get_proposition(verify_code)

    if pending_verify is None:
        app.logger.info('Failed to verify a non-existent subscription.')
        return flask.redirect('/')

    email_address = pending_verify['email_address']
    domain = pending_verify['domain']
    sub_id = tools.random_id()

    repository.subscribe_email(sub_id, email_address, domain)
    repository.remove_proposition(verify_code)

    return flask.render_template('www/email/subscribed.html', domain=domain)
コード例 #4
0
ファイル: email.py プロジェクト: dnssec/dnstwister
def email_subscribe_confirm_email(verify_code):
    """Handle email verification."""
    pending_verify = repository.get_proposition(verify_code)

    if pending_verify is None:
        app.logger.info(
            'Failed to verify a non-existent subscription with id: {}'.format(
                verify_code))
        return flask.redirect('/')

    email_address = pending_verify['email_address']
    domain = pending_verify['domain']
    sub_id = tools.random_id()

    repository.subscribe_email(sub_id, email_address, domain)
    repository.remove_proposition(verify_code)

    return flask.render_template('www/email/subscribed.html', domain=domain)