mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-09 10:09:49 -04:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user