Beispiel #1
0
def signup_post():
    form = RegistrationForm()
    if form.validate():
        email = request.form.get('email')
        name = request.form.get('name')
        password = request.form.get('password')
        print(email)
        print(name)
        print(password)

        new_user = User(email=email, name=name, password=generate_password_hash(password, method='sha256'))
        print(new_user)
        db.session.add(new_user)
        db.session.commit()
        flash('Thanks for registering')
        return redirect(url_for('auth.login'))
    return render_template('signup.html', form=form, error=form.errors)
Beispiel #2
0
def signup_post():
    try:
        form = RegistrationForm()
        if form.validate():
            email = request.form.get('email')
            name = request.form.get('name')
            password = request.form.get('password')
            new_user = User(email=email,
                            name=name,
                            password=generate_password_hash(password,
                                                            method='sha256'),
                            valid=False,
                            membership="None",
                            valid_till="None",
                            is_admin=False)
            db.session.add(new_user)
            db.session.commit()
            flash('Please Log in below')
            return redirect(url_for('main.profile'))
    except Exception:
        flash('Email already registered')
        render_template('signup.html', form=form, error=form.errors)

    return render_template('signup.html', form=form, error=form.errors)