def register(): if current_user.is_authenticated: return redirect(url_for('main.home')) form = RegistrationForm() if form.validate_on_submit(): hashed_passwor = bcrypt.generate_password_hash(form.password.data).decode('utf-8') user = User(username=form.username.data, email = form.email.data, password=hashed_passwor) db.session.add(user) db.session.commit() flash('Your account has been created! You are now able to log in', 'success') return redirect(url_for('user.login')) return render_template('register.html', title="register", form=form)
def Register(): if current_user.is_authenticated: return redirect(url_for('Main')) 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('Account Created for {}'.format(form.username.data), 'success') return redirect(url_for('Main')) return render_template('register.html', title='Register', form=form)
def register(): form = RegistrationForm() if form.validate_on_submit(): hash_password = bcrypt.generate_password_hash(form.password.data) user = User(name=form.name.data, username=form.username.data, email=form.email.data, password=hash_password) db.session.add(user) db.session.commit() return redirect(url_for('auth.login')) return render_template('register.html', form=form)
def register(): form = RegisterForm() if form.validate_on_submit(): pw_hash = bcrypt.generate_password_hash( form.password.data).decode('utf-8') user = User(username=form.username.data, email=form.email.data, password=pw_hash) db.session.add(user) db.session.commit() flash('Registration successful', 'success') return redirect(url_for('users.login')) return render_template('register.html', form=form)
def reset_token(token): if current_user.is_authenticated: return redirect(url_for('main.home')) user = User.verify_reset_token(token) if user is None: flash('That is an invalid or expired token', 'warning') return redirect(url_for('reset_request')) form = ResetPasswordForm() if form.validate_on_submit(): hashed_passwor = bcrypt.generate_password_hash(form.password.data).decode('utf-8') user.password = hashed_passwor db.session.commit() flash('Your account has been created! You are now able to log in', 'success') return redirect(url_for('user.login')) return render_template('reset_token.html', title='Rest Password', form=form)
def register(): if current_user.is_authenticated: return redirect(url_for('home')) form = RegisterForm() 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!', 'success') login_user(user, remember=False) return redirect(url_for('home')) return render_template('register.html', title='Register', form=form)
def change_password(): form = ChangePasswordForm() if form.validate_on_submit(): if bcrypt.check_password_hash(current_user.password, form.old_password.data): hashed_new_password = bcrypt.generate_password_hash( form.password.data).decode('utf-8') current_user.password = hashed_new_password db.session.commit() flash('Password changed!', 'success') return redirect(url_for('account')) else: flash('Error. Please check your email and password', 'danger') return render_template('change_password.html', title='Change Password', form=form)