def signup(): if current_user.is_authenticated: return redirect(url_for('home')) form = SignupForm() if form.validate_on_submit(): password = bcrypt.generate_password_hash( form.password.data).decode('utf-8') user = User(form.username.data, form.email.data, password) db.session.add(user) db.session.commit() flash(f'Congratulations {form.username.data} You Can Login Now !', 'success') return redirect(url_for('login')) return render_template('signup.html', title='Sign Up', form=form)
def signup(): if current_user.is_authenticated: return redirect(url_for('home')) form = SignupForm() 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'You have successfully created an account for {form.username.data}! You can now log in to your account', 'success') return redirect(url_for('signin')) return render_template('signup.html', form=form)