2016-02-17 09:51:54 +00:00
|
|
|
from flask import (
|
|
|
|
|
render_template,
|
|
|
|
|
)
|
2016-03-16 14:19:41 +00:00
|
|
|
from notifications_python_client.errors import HTTPError
|
2016-02-17 09:51:54 +00:00
|
|
|
|
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-03-07 18:18:52 +00:00
|
|
|
from app import user_api_client
|
2016-01-04 14:00:39 +00:00
|
|
|
|
|
|
|
|
|
2016-01-05 17:52:09 +00:00
|
|
|
@main.route('/forgot-password', methods=['GET', 'POST'])
|
|
|
|
|
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:
|
|
|
|
|
user_api_client.send_reset_password_url(form.email_address.data)
|
|
|
|
|
except HTTPError as e:
|
|
|
|
|
if e.status_code == 404:
|
|
|
|
|
return render_template('views/password-reset-sent.html')
|
|
|
|
|
else:
|
|
|
|
|
raise e
|
2016-03-07 18:18:52 +00:00
|
|
|
return render_template('views/password-reset-sent.html')
|
2016-01-27 18:01:43 +00:00
|
|
|
|
|
|
|
|
return render_template('views/forgot-password.html', form=form)
|