Skip to content

Instantly share code, notes, and snippets.

@pcustic
Created January 16, 2024 12:05
Show Gist options
  • Save pcustic/3f1ef451565e7e4225b26ee8f5bdb2e7 to your computer and use it in GitHub Desktop.
Save pcustic/3f1ef451565e7e4225b26ee8f5bdb2e7 to your computer and use it in GitHub Desktop.
add to app/auth/routes.py
@bp.route("/reset_password/<token>/<int:user_id>", methods=["GET", "POST"])
def reset_password(token, user_id):
if current_user.is_authenticated:
return redirect(url_for("main.index"))
user = User.validate_reset_password_token(token, user_id)
if not user:
return render_template(
"auth/reset_password_error.html", title="Reset Password error"
)
form = ResetPasswordForm()
if form.validate_on_submit():
user.set_password(form.password.data)
db.session.commit()
return render_template(
"auth/reset_password_success.html", title="Reset Password success"
)
return render_template(
"auth/reset_password.html", title="Reset Password", form=form
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment