我在重置密码时有一个奇怪的行为。我安装在dev fosuser bundle上。我重写登录模板,它的工作正常。但重置路线不能正常工作。 我的配置:
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>
当我提交提交按钮时,我被重定向到网址:/resetting/check-email
并且错误:No route found for "POST /resetting/check-email": Method Not Allowed (Allow: GET, HEAD)
。我没有收到电子邮件。你能帮我吗 ?对不起我的英文
答案 0 :(得分:2)
您应该在使用userbundle定位捆绑包的位置创建路由文件。 例如: 申请 - &gt;奏鸣曲 - &gt; UserBundle - &gt;资源 - &gt;配置 - &gt; 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>