<commit_before># coding: utf-8

"""
    views.py
    ~~~~~~~~

        视图文件
        /login: 统一登录页
        /logout: 统一登出页
"""

from . import auth
from .. import db
from ..models import User
from .forms import LoginForm, RegisterForm
from flask import render_template, redirect, request, url_for, flash
from flask.ext.login import login_user, login_required, logout_user, current_user
from ..redirect_urls import is_safe_url, get_redirect_target, redirect_back
import base64


@auth.route('/login/', methods=["POST", "GET"])
def login():
    """登录页面"""
    #next = get_redirect_target()
    form = LoginForm()
    if form.validate_on_submit():
        user = User.query.filter_by(username=form.username.data).first()
        if user is not None and user.verify_password(form.password.data):
            login_user(user)
            #return redirect_back('profile.user_profile', id=current_user.id)
            return redirect(url_for("share.index"))
        flash("用户名或密码不存在!")
    return render_template("muxi_login.html", form=form)#, next=next)


@auth.route('/register/', methods=["POST", "GET"])
def register():
    """注册页面"""
    form = RegisterForm()
    if form.validate_on_submit():
        user = User.query.filter_by(username=form.username.data).first()
        if user is not None:
            flash("username has been registered!")
            return redirect(url_for("auth.register"))
        elif form.password.data != form.passwordconfirm.data:
            flash("password do not match!")
            return redirect(url_for("auth.register"))
        else:
            user = User(
                    username=form.username.data,
                    email=form.email.data,
                    password=base64.b64encode(form.password.data),
                    role_id=2
                    )
            db.session.add(user)
            db.session.commit()
            return redirect(url_for("auth.login"))
    return render_template("muxi_register.html", form=form)


@login_required
@auth.route('/logout/')
def logout():
    """登出界面"""
    logout_user()
    return redirect('http://muxistudio.com/')
<commit_msg>update login<commit_after># coding: utf-8

"""
    views.py
    ~~~~~~~~

        视图文件
        /login: 统一登录页
        /logout: 统一登出页
"""

from . import auth
from .. import db
from ..models import User
from .forms import LoginForm, RegisterForm
from flask import render_template, redirect, request, url_for, flash
from flask.ext.login import login_user, login_required, logout_user, current_user
from ..redirect_urls import is_safe_url, get_redirect_target, redirect_back
import base64


@auth.route('/login/', methods=["POST", "GET"])
def login():
    """登录页面"""
    #next = get_redirect_target()
    form = LoginForm()
    if form.validate_on_submit():
        user = User.query.filter_by(username=form.username.data).first()
        if user is not None and user.verify_password(form.password.data):
            login_user(user)
            #return redirect_back('profile.user_profile', id=current_user.id)
            return redirect(url_for("shares.index"))
        flash("用户名或密码不存在!")
    return render_template("muxi_login.html", form=form)#, next=next)


@auth.route('/register/', methods=["POST", "GET"])
def register():
    """注册页面"""
    form = RegisterForm()
    if form.validate_on_submit():
        user = User.query.filter_by(username=form.username.data).first()
        if user is not None:
            flash("username has been registered!")
            return redirect(url_for("auth.register"))
        elif form.password.data != form.passwordconfirm.data:
            flash("password do not match!")
            return redirect(url_for("auth.register"))
        else:
            user = User(
                    username=form.username.data,
                    email=form.email.data,
                    password=base64.b64encode(form.password.data),
                    role_id=2
                    )
            db.session.add(user)
            db.session.commit()
            return redirect(url_for("auth.login"))
    return render_template("muxi_register.html", form=form)


@login_required
@auth.route('/logout/')
def logout():
    """登出界面"""
    logout_user()
    return redirect('http://muxistudio.com/')

{'fraction_non_alphanumeric': 0.13145539906103287, 'fraction_numerical': 0.003755868544600939, 'mean_word_length': 2.6171477079796266, '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': '5077573', 'n_tokens_mistral': 1291, 'n_tokens_neox': 1292, 'n_words': 267}