@auth.route('/reset', methods=['GET', 'POST'])
def password_reset_request():
    if (not current_user.is_anonymous):
        return redirect(url_for('main.index'))
    form = PasswordResetRequestForm()
    if form.validate_on_submit():
        user = User.query.filter_by(email=form.email.data).first()
        if user:
            token = user.generate_reset_token()
            send_email(user.email, 'Reset Your Password', 'auth/email/reset_password', user=user, token=token, next=request.args.get('next'))
            flash('An Email with instructions to reset your password has been sent to you.')
        else:
            flash('Email not registered')
        return redirect(url_for('auth.login'))
    return render_template('auth/reset_password.html', form=form)
@auth.route('/reset', methods=['GET', 'POST'])
def password_reset_request():
    if (not current_user.is_anonymous):
        return redirect(url_for('main.index'))
    form = PasswordResetRequestForm()
    if form.validate_on_submit():
        user = User.query.filter_by(email=form.email.data).first()
        if user:
            token = user.generate_reset_token()
            send_email(user.email, 'Reset Your Password', 'auth/email/reset_password', user=user, token=token, next=request.args.get('next'))
            flash('An Email with instructions to reset your password has been sent to you.')
        else:
            flash('Email not registered')
        return redirect(url_for('auth.login'))
    return render_template('auth/reset_password.html', form=form)