-
-
Save pcustic/3f1ef451565e7e4225b26ee8f5bdb2e7 to your computer and use it in GitHub Desktop.
add to app/auth/routes.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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