Ejemplo n.º 1
0
def register():
    form = forms.SignUpInForm()
    if form.validate_on_submit():
        models.User.new(
            email=form.email.data,
            password=form.password.data
        )
        flash("Thanks for registering!")
    return render_template('register.html', form=form)
Ejemplo n.º 2
0
def register():
    form = forms.SignUpInForm()
    if form.validate_on_submit():
        models.User.create_user(
            email=form.email.data,
            password=form.password.data
        )
        flash("Thanks for registering!")
    return redirect(url_for('index'))
Ejemplo n.º 3
0
def login():
    form = forms.SignUpInForm()
    if form.validate_on_submit():
        try:
            user = models.User.get(models.User.email == form.email.data)
            if check_password_hash(user.password, form.password.data):
                login_user(user)
                flash("You're now logged in!")
            else:
                flash("No user with that email/password combo")
        except models.DoesNotExist:
            flash("No user with that email/password combo")
    return render_template('register.html', form=form)
Ejemplo n.º 4
0
def login():
    form = forms.SignUpInForm()
    email = request.form.get('email')
    password = request.form.get('password')

    try:
        user = models.User.get(
            models.User.email == email
        )
        if check_password_hash(user.password, password):
            login_user(user)
            flash("You're now logged in!")
            return redirect(url_for('index'))
        else:
            flash("No user with that email/password combo")
    except models.DoesNotExist:
        flash("No user with that email/password combo")
    return render_template('login.html', form=form)