Implementation of the new_password endpoint.

Found a way to create the token that does not need to persist it to the database.
This requires proper error messages, written by people who speak menglis good.
This commit is contained in:
Rebecca Law
2016-01-07 17:13:49 +00:00
parent 8057a138a8
commit a860f713d2
17 changed files with 87 additions and 156 deletions

View File

@@ -1,5 +1,4 @@
from flask import render_template
from flask import render_template, flash
from app.main import main
from app.main.dao import users_dao
from app.main.forms import ForgotPasswordForm
@@ -8,10 +7,13 @@ from app.main.views import send_change_password_email
@main.route('/forgot-password', methods=['GET', 'POST'])
def forgot_password():
form = ForgotPasswordForm(users_dao.find_all_email_address())
form = ForgotPasswordForm()
if form.validate_on_submit():
user = users_dao.get_user_by_email(form.email_address.data)
send_change_password_email(form.email_address.data, user.id)
return render_template('views/password-reset-sent.html')
if users_dao.get_user_by_email(form.email_address.data):
send_change_password_email(form.email_address.data)
return render_template('views/password-reset-sent.html')
else:
flash('The email address is not recognized. Try again.')
return render_template('views/forgot-password.html', form=form)
else:
return render_template('views/forgot-password.html', form=form)