Exemplo n.º 1
0
def login():
    if current_user.is_authenticated():
        return redirect(request.args.get("next", '/'))

    if session.get('tfa-logged-in', False):
        del session['tfa-logged-in']
        del session['tfa-user']
        del session['tfa-remember']

    form = LoginForm(request.form)

    if request.method == "POST" and form.validate():
        try:
            user = authenticate_user(form.username.data, form.password.data)
        except LoginException, e:
            form.errors["login"] = [e.message]
            return render_template("login.html", form=form, title="Login")

        if user.tfa:
            session['tfa-logged-in'] = True
            session['tfa-user'] = user.name
            session['tfa-remember'] = form.remember.data
            return redirect(
                url_for('auth.verify', next=request.args.get('next')))

        #if not user.verified:
        #    flash(u"Please check your mail.")
        #    return redirect(url_for('auth.login', ext='html'))

        if login_user(user, remember=form.remember.data):
            flash("Logged in!", category="success")
            return redirect(request.args.get("next", '/'))
Exemplo n.º 2
0
def login():
    if current_user.is_authenticated():
        return redirect(request.args.get("next", '/'))

    if session.get('tfa-logged-in', False):
        del session['tfa-logged-in']
        del session['tfa-user']
        del session['tfa-remember']

    form = LoginForm(request.form)

    if request.method == "POST" and form.validate():
        try:
            user = authenticate_user(form.username.data, form.password.data)
        except LoginException, e:
            form.errors["login"] = [e.message]
            return render_template("login.html", form=form, title="Login")

        if user.tfa:
            session['tfa-logged-in'] = True
            session['tfa-user'] = user.name
            session['tfa-remember'] = form.remember.data
            return redirect(url_for('auth.verify', next=request.args.get('next')))

        #if not user.verified:
        #    flash(u"Please check your mail.")
        #    return redirect(url_for('auth.login', ext='html'))

        if login_user(user, remember=form.remember.data):
            flash("Logged in!", category="success")
            return redirect(request.args.get("next", '/'))
Exemplo n.º 3
0
def reauth():
    form = ReAuthForm(request.form)
    if request.method == "POST" and form.validate():
        try:
            user = authenticate_user(current_user.name, form.password.data)
        except LoginException, e:
            form.errors["login"] = [e.message]
            return render_template("reauth.html", form=form)

        confirm_login()  # Note: Cookies are a bit glitchy with the dev domains it seems, don't panic

        flash("Reauthenticated.", category="success")
        return redirect(request.args.get("next", "/"))
Exemplo n.º 4
0
def reauth():
    form = ReAuthForm(request.form)
    if request.method == "POST" and form.validate():
        try:
            user = authenticate_user(current_user.name, form.password.data)
        except LoginException, e:
            form.errors["login"] = [e.message]
            return render_template("reauth.html", form=form)

        confirm_login()  # Note: Cookies are a bit glitchy with the dev domains it seems, don't panic

        flash("Reauthenticated.", category="success")
        return redirect(request.args.get("next", '/'))