def registration(): form = RegistrationForm() if form.validate_on_submit(): username = request.form['username'] email = request.form['email'] password = request.form['password'] hashed_password = bcrypt.generate_password_hash(password).decode( 'utf-8') user = User(username=username, email=email, password=hashed_password) db.session.add(user) db.session.commit() flash('Your account has been created. You are ready to login.', 'success') return redirect(url_for("login")) return render_template('register.html', title='Register', form=form)
def register(): if current_user.is_authenticated: return redirect(url_for('home')) form = RegistrationForm() if form.validate_on_submit(): hashed_password = bcrypt.generate_password_hash( form.password.data).decode('utf-8') user = User(username=form.username.data, email=form.email.data, password=hashed_password) db.session.add(user) db.session.commit() flash(f'Account Created for {user.username}', 'success') return redirect(url_for('login')) return render_template('register.html', title='Register', form=form)
def register(): form = RegistrationForm() if form.validate_on_submit(): flash(f'Account created for {form.username.data}!', 'success') return redirect(url_for('home')) return render_template('register.html', title='Register', form=form)