def change_password(): form = PasswordResetForm() if form.validate_on_submit(): # Check that the user exists, and that the password is correct if bcrypt.check_password_hash(g.user.pwd_hash, form.current_password.data): g.user.pwd_hash = bcrypt.generate_password_hash(form.new_password.data) db.session.commit() # Redirect to the URL for the profile page flash("Password updated successfully!", "success") return redirect(url_for("profile.settingsProfile")) else: flash("Invalid Password", "danger") return render_template("settings.html", password_form=form, delete_form=DeleteProfileForm())
def register(): form = RegisterForm() if form.validate_on_submit(): user = User( form.firstName.data, form.lastName.data, form.username.data, form.email.data, bcrypt.generate_password_hash(form.password.data), ) db.session.add(user) db.session.commit() # Project 3: Steve - adding the automatic creation of the seeker, # provider objects associated with a user. seeker = Seeker(user.id) provider = Provider(user.id) db.session.add(seeker) db.session.add(provider) db.session.commit() flash("Registration Successful!", "success") return redirect(url_for(".login")) return render_template("register.html", form=form)