Ejemplo n.º 1
0
def login():
    if request.method == "POST":
        _logout()
        admin._logout()

        student_id = request.form["student_id"]
        password = request.form["password"]

        if not student_id in students_data:
            flash(u"Такого студента нет", "error")
            return redirect(request.url)

        try:
            checked = _check_password(student_id, password)

            if not checked:
                flash(u"Неверный пароль", "error")
                return redirect(request.url)

            _login(student_id)

            flash(u"Удачный вход", "success")
            return redirect(request.args.get("next", url_for("index")))

        except NoPassword:
            return redirect(
                url_for("students.set_password", student_id=student_id, next=request.args.get("next", url_for("index")))
            )

    else:
        return render_template("students/login.html")
Ejemplo n.º 2
0
def logout():
    admin._logout()
    _logout()
    flash(u"Вы вышли из системы", "success")
    return redirect(url_for("index"))