2020-10-05 15:51:44 +01:00
|
|
|
from flask import render_template, request
|
2016-03-16 14:19:41 +00:00
|
|
|
from notifications_python_client.errors import HTTPError
|
2016-02-17 09:51:54 +00:00
|
|
|
|
2018-02-20 11:22:17 +00:00
|
|
|
from app import user_api_client
|
2016-01-04 14:00:39 +00:00
|
|
|
from app.main import main
|
2016-01-05 17:52:09 +00:00
|
|
|
from app.main.forms import ForgotPasswordForm
|
2016-01-04 14:00:39 +00:00
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
@main.route("/forgot-password", methods=["GET", "POST"])
|
2016-01-05 17:52:09 +00:00
|
|
|
def forgot_password():
|
2016-01-28 16:36:36 +00:00
|
|
|
form = ForgotPasswordForm()
|
2016-01-04 14:00:39 +00:00
|
|
|
if form.validate_on_submit():
|
2016-03-16 14:19:41 +00:00
|
|
|
try:
|
2023-08-25 09:12:23 -07:00
|
|
|
user_api_client.send_reset_password_url(
|
|
|
|
|
form.email_address.data, next_string=request.args.get("next")
|
|
|
|
|
)
|
2016-03-16 14:19:41 +00:00
|
|
|
except HTTPError as e:
|
|
|
|
|
if e.status_code == 404:
|
2023-08-25 09:12:23 -07:00
|
|
|
return render_template("views/password-reset-sent.html")
|
2016-03-16 14:19:41 +00:00
|
|
|
else:
|
|
|
|
|
raise e
|
2023-08-25 09:12:23 -07:00
|
|
|
return render_template("views/password-reset-sent.html")
|
2016-01-27 18:01:43 +00:00
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
return render_template("views/forgot-password.html", form=form)
|