def register(): db.drop_all() db.create_all() hashed_password = bcrypt.generate_password_hash('22888').decode('utf-8') user = User(username='******', email='*****@*****.**', password=hashed_password) db.session.add(user) db.session.commit()
def register(): if current_user.is_authenticated: return redirect(url_for('index')) form = RegistrationForm() if form.validate_on_submit(): hashed_pwd = bcrypt.generate_password_hash(form.password.data) user = User(username=form.username.data, email=form.email.data, password=hashed_pwd) db.session.add(user) db.session.commit() flash('Registraion Successfull !!') return redirect(url_for('login')) elif form.errors: flash("Registration unsuccessful. Please try again") return redirect(url_for('register')) return render_template('register.html', title='register', form=form)
def register(): form = RegistrationForm() if request.method == "POST": 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("Account created !") return redirect(url_for('login')) if form.errors: flash("Validation Errors:" + str(form.errors)) app.logger.error('ValidationError:\n' + str(form.errors)) return render_template('register.html', title='Register', form=form)
def register(): if (current_user.is_authenticated): return redirect(url_for('index')) form = RegistrationForm() if form.validate_on_submit(): hashed_password = bcrypt.generate_password_hash(form.password.data) user = User(username=form.username.data, email=form.email.data, password=hashed_password) db.session.add(user) db.session.commit() flash('Account created !') return redirect(url_for('login')) if form.errors: flash('Validation Errors: ' + str(form.errors)) app.logger.error('ValidationError:\n' + str(form.errors)) return render_template('register.html', title='Register', form=form)