@auth.route('/login', methods=['GET', 'POST'])
def log_in():
    form = LoginForm(request.form)

    if form.validate_on_submit():
        user = User.query.filter_by(email=form.email.data).first()
        if user is not None and user.verify_password(form.password.data):
            session['user_id'] = user.id

            # Send a request to verify this user's login with OneTouch
            one_touch_response = user.send_one_touch_request()

            return jsonify(one_touch_response)
        else:
            # The username and password weren't valid
            form.errors['Invalid credentials'] = ['The username and password combination you entered are invalid']

    if request.method == 'POST':
        # This was an AJAX request, and we should return our form errors as JSON
        return jsonify({'invalid_credentials': render_template('_login_error.html', form=form)})
    else:
        return render_template('login.html', form=form)
Powers the main login form.
dataset/ETHPy150Open TwilioDevEd/authy2fa-flask/twofa/auth/views.py/log_in