<commit_before>from flask import render_template, redirect, request, url_for, flash
from flask_login import logout_user, login_user
from . import auth
from .. import db
from ..models import Users
from .forms import LoginForm, RegistrationForm


@auth.route('/login', methods=['GET', 'POST'])
def login():
    form = LoginForm(request.form)
    if form.validate_on_submit():
        # Login and validate the user.
        # user should be an instance of your `Users` class
        user = Users.query.filter_by(username=form.username.data).first()
        if user is not None and user.verify_password(form.password.data):
            user.authenticated = True
            login_user(user, form.remember.data)
            flash('Welcome %s' % user.username)
        # next_is_valid should check if the user has valid
        # permission to access the `next` url
            return redirect(request.args.get('next') or url_for('store.index'))
        # return redirect(request.args.get('next') or url_for('main.home'))
        flash('Invalid username or password.')
        # if login not successful, return to login page
    return render_template('auth/login.html', form=form)


@auth.route('/logout')
# @login_required
def logout():
    logout_user()
    flash('You have been logged out.')
    # retuns user to the index page<commit_msg>this package contains the authentication files for login and signup<commit_after>from flask import render_template, redirect, request, url_for, flash
from flask_login import logout_user, login_user
from . import auth
from .. import db
from ..models import Users
from .forms import LoginForm, RegistrationForm


@auth.route('/login', methods=['GET', 'POST'])
def login():
    form = LoginForm(request.form)
    if form.validate_on_submit():
        # Login and validate the user.
        # user should be an instance of your `Users` class
        user = Users.query.filter_by(username=form.username.data).first()
        if user is not None and user.verify_password(form.password.data):
            user.authenticated = True
            login_user(user, form.remember.data)
            flash('Welcome %s' % user.username)
        # next_is_valid should check if the user has valid
        # permission to access the `next` url
            return redirect(request.args.get('next') or url_for('store.index'))
        # return redirect(request.args.get('next') or url_for('main.home'))
        flash('Invalid username or password.')
        # if login not successful, return to login page
    return render_template('auth/login.html', form=form)


@auth.route('/logout')
# @login_required
def logout():
    logout_user()
    # flash('You have been logged out.')
    # retuns user to the index page
{'fraction_non_alphanumeric': 0.10586080586080586, 'fraction_numerical': 0.0, 'mean_word_length': 3.2472783825816487, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '718308', 'n_tokens_mistral': 760, 'n_tokens_neox': 743, 'n_words': 248}