Ejemplo n.º 1
0
 def test_validate_inactive_user(self, user):
     user.active = False
     user.set_password('example')
     user.save()
     # Correct username and password, but user is not activated
     form = LoginForm(username=user.username, password='******')
     assert form.validate() is False
     assert 'User not activated' in form.username.errors
Ejemplo n.º 2
0
 def test_validate_inactive_user(self, user):
     user.active = False
     user.set_password('example')
     user.save()
     # Correct username and password, but user is not activated
     form = LoginForm(username=user.username, password='******')
     assert form.validate() is False
     assert 'User not activated' in form.username.errors
Ejemplo n.º 3
0
def login():
    form = LoginForm(request.form)
    # Handle logging in
    if request.method == 'POST':
        if form.validate_on_submit():
            login_user(form.user)
            flash("You are logged in.", 'success')
            redirect_url = request.args.get("next") or url_for("public.home")
            return redirect(redirect_url)
        else:
            flash_errors(form)
    if (request.referrer or request.args.get("next")):
        next_url = request.args.get("next") or request.referrer
        return render_template('public/login.html', login_form=form, 
            next_url=next_url)
    else:
        return render_template('public/login.html', login_form=form)
def login():
    form = LoginForm(request.form)
    # Handle logging in
    if request.method == 'POST':
        if form.validate_on_submit():
            login_user(form.user)
            flash("You are logged in.", 'success')
            redirect_url = request.args.get("next") or url_for("public.home")
            return redirect(redirect_url)
        else:
            flash_errors(form)
    if (request.referrer or request.args.get("next")):
        next_url = request.args.get("next") or request.referrer
        return render_template('public/login.html',
                               login_form=form,
                               next_url=next_url)
    else:
        return render_template('public/login.html', login_form=form)
Ejemplo n.º 5
0
 def test_validate_invalid_password(self, user):
     user.set_password('example')
     user.save()
     form = LoginForm(username=user.username, password='******')
     assert form.validate() is False
     assert 'Invalid password' in form.password.errors
Ejemplo n.º 6
0
 def test_validate_unknown_username(self, db):
     form = LoginForm(username='******', password='******')
     assert form.validate() is False
     assert 'Unknown username' in form.username.errors
     assert form.user is None
Ejemplo n.º 7
0
 def test_validate_success(self, user):
     user.set_password('example')
     user.save()
     form = LoginForm(username=user.username, password='******')
     assert form.validate() is True
     assert form.user == user
Ejemplo n.º 8
0
 def test_validate_invalid_password(self, user):
     user.set_password('example')
     user.save()
     form = LoginForm(username=user.username, password='******')
     assert form.validate() is False
     assert 'Invalid password' in form.password.errors
Ejemplo n.º 9
0
 def test_validate_unknown_username(self, db):
     form = LoginForm(username='******', password='******')
     assert form.validate() is False
     assert 'Unknown username' in form.username.errors
     assert form.user is None
Ejemplo n.º 10
0
 def test_validate_success(self, user):
     user.set_password('example')
     user.save()
     form = LoginForm(username=user.username, password='******')
     assert form.validate() is True
     assert form.user == user
def about():
    form = LoginForm(request.form)
    return render_template("public/about.html", form=form)