-2

我在重置密码时有一个奇怪的行为。我安装在 dev fosuser 包上。我覆盖了登录模板,它工作正常。但重置路线不能正常工作。我的配置:

swiftmailer:
   transport: gmail
   username:  myEmail@gmail.com
   password:  passowrd
   spool:     { type: memory }
fos_user:
   db_driver: orm
   user_class: App\DesktopBundle\Entity\User
   firewall_name: main
   service:
      mailer: fos_user.mailer.twig_swift
   resetting:
      token_ttl: 86400 # change this value, it is in seconds = 24 hours
      email:
        template:   email/password_resetting.email.twig
   from_email:
        address:        noreply@acmedemo.com
        sender_name:    Title Email

我创建了一个文件:/app/Resources/FOSUserBundle/views/Resetting/request.html.twig

<div class="row">
    <div class="col-md-3 col-sm-3">
    </div>
    <div class="col-md-5 col-sm-5" style="margin-top: 3%">

        <div class="title-area" style="margin-bottom: 2%;">
            <h2 class="title">Reset</h2>
            <span class="line"></span>
        </div>

        <form action="{{ path('fos_user_resetting_check_email') }}" method="POST" class="comments-form contact-form">
            <div>
                {% if invalid_username is defined %}
                    <p>{{ 'resetting.request.invalid_username'|trans({'%username%': invalid_username}) }}</p>
                {% endif %}
                <div class="input-group" style="margin-bottom: 2%;">
                    <span class="input-group-addon"><i class="fa fa-user"></i></span>
                    <input class="form-control" placeholder="Login" type="text" id="username" name="username" required="required" style="height: 55px;font-size: 20px;">
                </div>
            </div>
            <div>
                <input type="submit" value="Reset" class="btn btn-lg btn-primary btn-block"/>
            </div>
        </form>
    </div>
    <div class="col-md-3 col-sm-3">
        <div class="right-bloc-pub" style="width:300px; height: 600px; background:red; margin-top:13%;">
        </div>
    </div>
</div>

当我按下提交按钮时,我被重定向到 url:/resetting/check-email和错误: No route found for "POST /resetting/check-email": Method Not Allowed (Allow: GET, HEAD)。而且我没有收到电子邮件。你能帮我吗 ?对不起我的英语不好

4

1 回答 1

3

您应该在使用 userbundle 找到您的捆绑包的地方创建路由文件。例如: Application -> Sonata -> UserBundle -> Resources -> Config -> admin_resetting.xml 来自 admin_resetting.xml 的代码

<?xml version="1.0" encoding="UTF-8" ?>

<routes xmlns="http://symfony.com/schema/routing"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">

    <route id="sonata_user_admin_resetting_request" path="/request" methods="GET">
        <default key="_controller">SonataUserBundle:AdminResetting:request</default>
    </route>

    <route id="sonata_user_admin_resetting_send_email" path="/send-email" methods="POST">
        <default key="_controller">SonataUserBundle:AdminResetting:sendEmail</default>
    </route>

    <route id="sonata_user_admin_resetting_check_email" path="/check-email" methods="GET">
        <default key="_controller">SonataUserBundle:AdminResetting:checkEmail</default>
    </route>

    <route id="sonata_user_admin_resetting_reset" path="/reset/{token}" methods="GET POST">
        <default key="_controller">SonataUserBundle:AdminResetting:reset</default>
    </route>

</routes>
于 2016-10-28T08:55:35.153 回答