예제 #1
0
def reset_token(token):
	user = User.verify_reset_token(token)
	if user is None:
		flash('This token is either invalid or expired.', 'warning')
		return redirect(url_for('reset_request'))
	
	form = ResetPasswordForm()
	if form.validate_on_submit():
		hashed_password = bcrypt.generate_password_hash(form.password.data).decode('utf-8')
		user.password = hashed_password
		db.session.commit()
		flash(f'Your password is updated.', 'success')
		return redirect(url_for('login'))
	return render_template('reset_token.html', title='Reset Password', form=form)
예제 #2
0
def signup():
	if current_user.is_authenticated:
		flash('You have been logged in as ' + current_user.username + '. Please logout from this account to sign in with different account.', 'warning')
		return redirect('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'Your account has been created.', 'success')
		login_user(user)
		return redirect(url_for('home'))
	return render_template('signup.html', title='Signup', form=form)
예제 #3
0
def signup():
    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'Your account has been created.', 'success')
        login_user(user)
        return redirect(url_for('home'))
    return render_template('signup.html', title='Signup', form=form)