<commit_before>from app.core.controllers import *
from app.auth.forms import LoginForm, AdminForm
from app.auth.models import User

# Define the blueprint: 'auth', set its url prefix: app.url/auth
mod_auth = Blueprint('auth', __name__, url_prefix='/auth')

@mod_auth.route('/login/', methods=['GET', 'POST'])
def login():
    if session['user_id']:
        return redirect('/posts/')

    form = LoginForm(request.form)
    # Verify the sign in form
    if form.validate_on_submit():
        user = User.query(User.email == form.email.data).get()
        if user and check_password_hash(user.password, form.password.data):
            session['user_id'] = user.key.id()
            flash('Welcome %s' % user.name)
            return redirect('/posts/')

        flash('Invalid email or password', 'error')

    return render_template("auth/signin.html", form=form)

@mod_auth.route('/logout/')
def logout():
    session.pop('user_id', None)
    return redirect('/auth/login/')<commit_msg>fix bug on check session<commit_after>from app.core.controllers import *
from app.auth.forms import LoginForm, AdminForm
from app.auth.models import User

# Define the blueprint: 'auth', set its url prefix: app.url/auth
mod_auth = Blueprint('auth', __name__, url_prefix='/auth')

@mod_auth.route('/login/', methods=['GET', 'POST'])
def login():
    if 'user_id' in session:
        return redirect('/posts/')

    form = LoginForm(request.form)
    # Verify the sign in form
    if form.validate_on_submit():
        user = User.query(User.email == form.email.data).get()
        if user and check_password_hash(user.password, form.password.data):
            session['user_id'] = user.key.id()
            flash('Welcome %s' % user.name)
            return redirect('/posts/')

        flash('Invalid email or password', 'error')

    return render_template("auth/signin.html", form=form)

@mod_auth.route('/logout/')
def logout():
    session.pop('user_id', None)
    return redirect('/auth/login/')
{'fraction_non_alphanumeric': 0.14982403217697335, 'fraction_numerical': 0.0, 'mean_word_length': 3.4320712694877504, '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': '5539812', 'n_tokens_mistral': 612, 'n_tokens_neox': 605, 'n_words': 151}