@auth.route('/reset-password', methods=['GET', 'POST'])
def forgot_password():
 if (not current_user.is_anonymous):
  return redirect(url_for('forum.index'))
 form = ForgotPasswordForm()
 if form.validate_on_submit():
  user = User.query.filter_by(email=form.email.data).first()
  if user:
   send_reset_token.delay(user)
   flash(_('Email sent! Please check your inbox.'), 'info')
   return redirect(url_for('auth.forgot_password'))
  else:
   flash(_('You have entered an username or email address that is not linked with your account.'), 'danger')
 return render_template('auth/forgot_password.html', form=form)

@ auth . route ( '/reset-password' , methods = [ 'GET' , 'POST' ] ) def forgot_password ( ) : if ( not current_user . is_anonymous ) : return redirect ( url_for ( 'forum.index' ) ) form = ForgotPasswordForm ( ) if form . validate_on_submit ( ) : user = User . query . filter_by ( email = form . email . data ) . first ( ) if user : send_reset_token . delay ( user ) flash ( _ ( 'Email sent! Please check your inbox.' ) , 'info' ) return redirect ( url_for ( 'auth.forgot_password' ) ) else : flash ( _ ( 'You have entered an username or email address that is not linked with your account.' ) , 'danger' ) return render_template ( 'auth/forgot_password.html' , form = form )
view function that handles a forgotten password request .