@auth.route('/reset-password/<token>', methods=['GET', 'POST'])
def reset_password(token):
 if (not current_user.is_anonymous):
  return redirect(url_for('forum.index'))
 form = ResetPasswordForm()
 if form.validate_on_submit():
  (expired, invalid, user) = get_token_status(form.token.data, 'reset_password')
  if invalid:
   flash(_('Your password token is invalid.'), 'danger')
   return redirect(url_for('auth.forgot_password'))
  if expired:
   flash(_('Your password token is expired.'), 'danger')
   return redirect(url_for('auth.forgot_password'))
  if user:
   user.password = form.password.data
   user.save()
   flash(_('Your password has been updated.'), 'success')
   return redirect(url_for('auth.login'))
 form.token.data = token
 return render_template('auth/reset_password.html', form=form)

@ auth . route ( '/reset-password/<token>' , methods = [ 'GET' , 'POST' ] ) def reset_password ( token ) : if ( not current_user . is_anonymous ) : return redirect ( url_for ( 'forum.index' ) ) form = ResetPasswordForm ( ) if form . validate_on_submit ( ) : ( expired , invalid , user ) = get_token_status ( form . token . data , 'reset_password' ) if invalid : flash ( _ ( 'Your password token is invalid.' ) , 'danger' ) return redirect ( url_for ( 'auth.forgot_password' ) ) if expired : flash ( _ ( 'Your password token is expired.' ) , 'danger' ) return redirect ( url_for ( 'auth.forgot_password' ) ) if user : user . password = form . password . data user . save ( ) flash ( _ ( 'Your password has been updated.' ) , 'success' ) return redirect ( url_for ( 'auth.login' ) ) form . token . data = token return render_template ( 'auth/reset_password.html' , form = form )
view function that handles a reset password request .