#NEWLINE# @ auth_views . route ( '/accounts/password/reset' , methods = [ 'GET' , 'POST' ] ) #NEWLINE# def reset_password( ) : #NEWLINE# #INDENT# if ( request . method == 'POST' ) : #NEWLINE# #INDENT# form = ResetPasswordForm ( request . form ) #NEWLINE# if form . validate ( ) : #NEWLINE# #INDENT# user = User . objects . get ( email = form . email . data ) #NEWLINE# password_reset_token = user . generate_password_reset_token ( ) #NEWLINE# host = request . headers [ 'HOST' ] #NEWLINE# link = ( 'http://%s/accounts/password/reset/%s' % ( host , password_reset_token ) ) #NEWLINE# mesg = ( 'Hi %s,\n\nSomeone (probably you) requested for a password reset at %s. Please visit the following link if you wish to reset your password:\n\n%s\n\nHave a good day!' % ( user . name , host , link ) ) #NEWLINE# send_mail ( ( '[%s] Reset Password' % host ) , mesg , current_app . config [ 'SERVER_EMAIL' ] , [ mesg . email ] , fail_silently = False ) #NEWLINE# flash ( 'Sent you a mail to reset the password. Do remember to check your spam folder as well.' , 'success' ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# form = ResetPasswordForm ( ) #NEWLINE# #UNINDENT# return render_template ( 'auth/reset_password.html' , ** locals ( ) )