Ejemplo n.º 1
0
 def test_validate_success(self, user):
     """Login successful."""
     user.set_password('example')
     user.save()
     form = LoginForm(username=user.username, password='******')
     assert form.validate() is True
     assert form.user == user
Ejemplo n.º 2
0
 def test_validate_success(self, user):
     """Login successful."""
     user.set_password('example')
     user.save()
     form = LoginForm(username=user.username, password='******')
     assert form.validate() is True
     assert form.user == user
Ejemplo n.º 3
0
 def test_validate_invalid_password(self, user):
     """Invalid password."""
     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.º 4
0
 def test_validate_invalid_password(self, user):
     """Invalid password."""
     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.º 5
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.º 6
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.º 7
0
 def test_validate_inactive_user(self, user):
     """Inactive 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.º 8
0
def home():
    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("user.members")
            return redirect(redirect_url)
        else:
            flash_errors(form)
    return render_template("public/home.html", form=form)
Ejemplo n.º 9
0
def home():
    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("user.members")
            return redirect(redirect_url)
        else:
            flash_errors(form)
    return render_template("public/home.html", form=form)
Ejemplo n.º 10
0
def home():
    """Home page."""
    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('user.members')
            return redirect(redirect_url)
        else:
            flash_errors(form)
    return render_template('public/home.html', form=form)
Ejemplo n.º 11
0
def login():
    form = LoginForm()
    if form.validate_on_submit():
        user = User.query.filter_by(username=form.username.data).first()
        if user is not None:
            if user.check_password(form.password.data):
                login_user(user)
                return redirect(url_for('public.index'))
            else:
                flash("wrong password", "danger")
        else:
            flash("uknown user", "danger")
    return render_template('public/login.html', form=form)
Ejemplo n.º 12
0
def home():
    """Home page."""
    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('user.members')
            return redirect(redirect_url)
        else:
            flash_errors(form)
    return render_template('public/home.html', form=form)
Ejemplo n.º 13
0
def home():
    """Home page."""
    form = LoginForm(request.form)
    current_app.logger.info("Hello from the home page!")
    # 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("user.members")
            return redirect(redirect_url)
        else:
            flash_errors(form)
    return render_template("public/home.html", form=form)
Ejemplo n.º 14
0
def index():
    if current_user.is_authenticated:
        return redirect(url_for('main.index'))
    form = LoginForm()
    return render_template('public/index.html', form=form)
Ejemplo n.º 15
0
def about():
    """About page."""
    form = LoginForm(request.form)
    return render_template("public/about.html", form=form)
Ejemplo n.º 16
0
def customerHome():
    """Customer Home."""
    form = LoginForm(request.form)
    return render_template("public/customerHome.html", form=form)
Ejemplo n.º 17
0
 def test_validate_unknown_username(self, db):
     """Unknown username."""
     form = LoginForm(username='******', password='******')
     assert form.validate() is False
     assert 'Unknown username' in form.username.errors
     assert form.user is None
Ejemplo n.º 18
0
def customerShoppingCart():
    """Customer Shopping Cart."""
    form = LoginForm(request.form)
    return render_template("public/customerShoppingCart.html", form=form)
Ejemplo n.º 19
0
def customerDeliveryRating():
    """Customer Delivery Rating."""
    form = LoginForm(request.form)
    return render_template("public/customerDeliveryRating.html", form=form)
Ejemplo n.º 20
0
 def test_validate_unknown_username(self, db):
     """Unknown username."""
     form = LoginForm(username='******', password='******')
     assert form.validate() is False
     assert 'Unknown username' in form.username.errors
     assert form.user is None
Ejemplo n.º 21
0
 def test_validate_unknown_username(self, db):
     """Unknown username."""
     form = LoginForm(username="******", password="******")
     assert form.validate() is False
     assert "Unknown username" in form.username.errors
     assert form.user is None