Ejemplo n.º 1
0
def authenticated_request(client):
    new_user = User(email="*****@*****.**")
    new_user.set_password("123456")
    db.session.add(new_user)
    db.session.commit()

    response = client.post(
        url_for("user.login"),
        data={"email": "*****@*****.**", "password": "******"},
        follow_redirects=True,
    )
    yield client
Ejemplo n.º 2
0
def register():
    if current_user.is_authenticated:
        return redirect(url_for('index'))
    form = RegistrationForm()
    if form.validate_on_submit():
        user = User(username=form.username.data, email=form.email.data)
        user.set_password(form.password.data)
        db.session.add(user)
        db.session.commit()
        flash('Congratulations, you are now a registered user')
        return redirect(url_for('index'))
    return render_template('registration.html', title='register', form=form)
Ejemplo n.º 3
0
def register():

    if current_user.is_authenticated:
        flash("You are already logged in", "warning")
        return redirect(url_for("landing.index"))

    form = RegisterForm()
    if form.validate_on_submit():

        user = User(email=form.email.data)
        user.set_password(form.password.data)

        db.session.add(user)
        db.session.commit()
        login_user(user)

        flash("Registered successfully", "success")

        return redirect(url_for("landing.index"))

    return render_template("users/register.html", form=form)
Ejemplo n.º 4
0
def create_user(email=EXAMPLE_EMAIL, password=EXAMPLE_PASSWORD):
    user = User(email=email)
    user.set_password(password)
    db.session.add(user)
    db.session.commit()
    return user