#NEWLINE# @ frontend . route ( '/reset_password' , methods = [ 'GET' , 'POST' ] ) #NEWLINE# def reset_password( ) : #NEWLINE# #INDENT# form = RecoverPasswordForm ( ) #NEWLINE# if form . validate_on_submit ( ) : #NEWLINE# #INDENT# user = User . query . filter_by ( email = form . email . data ) . first ( ) #NEWLINE# if form : #NEWLINE# #INDENT# flash ( 'Please see your email for instructions on how to access your account' , 'success' ) #NEWLINE# user . activation_key = str ( uuid4 ( ) ) #NEWLINE# db . session . add ( user ) #NEWLINE# db . session . commit ( ) #NEWLINE# url = url_for ( 'frontend.change_password' , email = user . email , activation_key = user . activation_key , _external = True ) #NEWLINE# html = render_template ( 'macros/_reset_password.html' , project = current_app . config [ 'PROJECT' ] , username = user . name , url = url ) #NEWLINE# message = Message ( subject = ( 'Reset your password in ' + current_app . config [ 'PROJECT' ] ) , html = html , recipients = [ user . email ] ) #NEWLINE# mail . send ( message ) #NEWLINE# return render_template ( 'frontend/reset_password.html' , form = form ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# flash ( _ ( 'Sorry, no user found for that email address' ) , 'error' ) #NEWLINE# #UNINDENT# #UNINDENT# return render_template ( 'frontend/reset_password.html' , form = form )