def do_login():
    """ Attempt to auth using single login. Rate limited at the site level. """

    dt_filter = lambda x: x >= datetime.utcnow() - timedelta(seconds=60)
    app.config['AUTH_ATTEMPTS'] = filter(dt_filter, app.config['AUTH_ATTEMPTS'])

    if len(app.config['AUTH_ATTEMPTS']) > app.config['AUTH_RATE_LIMIT']:
        return redirect(url_for('login',
                                alert="Rate limit exceeded. Try again in 60 seconds."))

    if request.form.get('password') == app.config['APP_PASSWORD']:
        login_user(SingleAuthUser)
        return redirect('/')

    app.config['AUTH_ATTEMPTS'].append(datetime.utcnow())
    return redirect(url_for('login', alert="Incorrect password."))
Attempt to auth using single login. Rate limited at the site level.