我正在尝试使用FOSUser进行密码恢复。对我来说,一切正常,直到我尝试转到重置密码页面。
我的电子邮件链接如下:
但是当我尝试继续时,FOS会重定向我
/ resetting / request path
这就是我在日志文件中的内容:
[2017-02-21 13:22:18] request.INFO:匹配路线 “fos_user_resetting_reset”。 { “路线”: “fos_user_resetting_reset”, “route_parameters”:{ “_控制器”: “FOS \ UserBundle \控制器\ ResettingController :: resetAction”, “_区域”: “恩”, “令牌”: “RYPuGNDgSel85v1Kcj3lrIqPRhuYt5inh3VQAOlRPgk”, “_路线” : “fos_user_resetting_reset”}, “REQUEST_URI”: “http://localhost/yaaholidays/web/app_dev.php/en/resetting/reset/RYPuGNDgSel85v1Kcj3lrIqPRhuYt5inh3VQAOlRPgk”, “方法”: “GET”} []
[2017-02-21 13:22:18] security.INFO:填充了TokenStorage 一个匿名的令牌。 [] []
[2017-02-21 13:22:18] doctrine.DEBUG:SELECT t0.username AS username_1,t0.username_canonical AS username_canonical_2,t0.email AS email_3,t0.email_canonical AS email_canonical_4,t0.enabled AS enabled_5,t0.salt AS salt_6,t0.password AS password_7,t0.last_login AS last_login_8,t0.confirmation_token AS confirmation_token_9, t0.password_requested_at AS password_requested_at_10,t0.roles AS roles_11,t0.id AS id_12,t0.salutation AS salutation_13, t0.first_name AS first_name_14,t0.surname AS surname_15, t0.phone_number AS phone_number_16,t0.profile_picture AS profile_picture_17,t0.languages AS languages_18,t0.address AS address_19,t0.agency AS agency_20 FROM fos_user t0 WHERE t0.confirmation_token =?限制1 [“RYPuGNDgSel85v1Kcj3lrIqPRh [...]”] []
[2017-02-21 13:22:18] request.INFO:匹配路线 “fos_user_resetting_request”。 { “路线”: “fos_user_resetting_request”, “route_parameters”:{ “_控制器”: “FOS \ UserBundle \控制器\ ResettingController :: requestAction”, “_区域设置”: “EN”, “_路线”: “fos_user_resetting_request”},“REQUEST_URI “:”http://localhost/yaaholidays/web/app_dev.php/en/resetting/request”, “方法”: “GET”} []
[2017-02-21 13:22:18] security.INFO:填充了TokenStorage 一个匿名的令牌。 [] []
[2017-02-21 13:22:18]翻译。警告:找不到翻译。 {“id”:“Telefon”,“domain”:“messages”,“locale”:“en”} []
[2017-02-21 13:22:19] request.INFO:匹配路由“_wdt”。 { “路线”: “_ WDT”, “route_parameters”:{ “_控制器”: “web_profiler.controller.profiler:toolbarAction”, “令牌”: “6f0aa9”, “_路线”: “_ WDT”, “_区域”:“恩“},” REQUEST_URI “:”http://localhost/yaaholidays/web/app_dev.php/_wdt/6f0aa9”, “方法”: “GET”} []
有人知道为什么FOS会在密码恢复请求页面上重定向我而不是设置新的密码页面吗?
答案 0 :(得分:3)
通过阅读日志,密码重置请求似乎已过期。您的链接是否已过期?
在控制器FOS \ UserBundle \ Controller \ ResettingController中,刚刚从令牌获取用户后添加事件RESETTING_RESET_INITIALIZE,然后调用侦听器ResettingListener。在此侦听器中,onResettingResetInitialize方法(管理RESETTING_RESET_INITIALIZE事件)检查密码请求是否过期,如果是,则重定向到路由fos_user_resetting_request:
/**
* @param GetResponseUserEvent $event
*/
public function onResettingResetInitialize(GetResponseUserEvent $event)
{
if (!$event->getUser()->isPasswordRequestNonExpired($this->tokenTtl)) {
$event->setResponse(new RedirectResponse($this->router->generate('fos_user_resetting_request')));
}
}
如果您刚刚收到重置密码的电子邮件且链接尚未过期,请在config.xml中检查您的fosuser配置。
如果你有这样的事情:
fos_user:
resetting:
token_ttl: 0
然后你的令牌ttl将永远无效。在这种情况下,例如将令牌ttl更改为86400(1天)。