コード例 #1
0
def login():

    form = LoginForm(request.form)

    # POST
    if request.method == 'POST':

        if not form.validate():
            return render_template('login.html',
                                   form=form,
                                   message='Введены некорректные данные')

        login = form.login.data
        password = form.password.data
        remember_me = form.remember_me.data

        result = get_user_info(login, password)

        if result is not False and result is not None:
            session.permanent = remember_me
            session['login'] = login
            session['password'] = password
            return redirect('/')
        return render_template(
            'login.html',
            title="Вход",
            form=form,
            message='Вход не удался. Возможно введены неверные данные')

    # GET
    if auth():
        return redirect('/')
    return render_template('login.html', title="Вход", form=form)
コード例 #2
0
ファイル: views.py プロジェクト: TheTypoMaster/paralarea
def login():

    form = LoginForm(request.form)

    # POST
    if request.method == "POST":

        if not form.validate():
            return render_template("login.html", form=form, message="Введены некорректные данные")

        login = form.login.data
        password = form.password.data
        remember_me = form.remember_me.data

        result = get_user_info(login, password)

        if result is not False and result is not None:
            session.permanent = remember_me
            session["login"] = login
            session["password"] = password
            return redirect("/")
        return render_template(
            "login.html", title="Вход", form=form, message="Вход не удался. Возможно введены неверные данные"
        )

    # GET
    if auth():
        return redirect("/")
    return render_template("login.html", title="Вход", form=form)
コード例 #3
0
def auth():

    login = session.get('login')
    password = session.get('password')

    if login is None or password is None:
        return False

    user_info = get_user_info(login, password)

    return user_info is not False and user_info is not None
コード例 #4
0
ファイル: views.py プロジェクト: TheTypoMaster/paralarea
def auth():

    login = session.get("login")
    password = session.get("password")

    if login is None or password is None:
        return False

    user_info = get_user_info(login, password)

    return user_info is not False and user_info is not None