我剛開始使用fosuserbundle,今天我激活了確認註冊鏈接。 它的偉大工程,但如果用戶點擊第二次郵件中的確認鏈接,他得到這個錯誤:當雙擊確認鏈接時,進入fosuserbundle的問題?
與確認令牌用戶「3hiqollkisg0s4ck4w8g0gw4soc0wwoo8ko084o4ww4sss8o4」不存在 404未找到 - NotFoundHttpException
我認爲這個錯誤應該由捆綁處理,不是嗎?
謝謝
我剛開始使用fosuserbundle,今天我激活了確認註冊鏈接。 它的偉大工程,但如果用戶點擊第二次郵件中的確認鏈接,他得到這個錯誤:當雙擊確認鏈接時,進入fosuserbundle的問題?
與確認令牌用戶「3hiqollkisg0s4ck4w8g0gw4soc0wwoo8ko084o4ww4sss8o4」不存在 404未找到 - NotFoundHttpException
我認爲這個錯誤應該由捆綁處理,不是嗎?
謝謝
下面是覆蓋操作的代碼。基本上只是複製了實際FOS動作的一部分並進行了修改。
在您的用戶包的控制器文件夾中創建一個RegistrationController.php文件,並將重寫的RegistrationController類放在那裏。
假設你的用戶包是Acme的\ UserBundle:
<?php
// Acme\UserBundle\RegistrationController.php
namespace Acme\UserBundle\Controller;
use Symfony\Component\HttpFoundation\RedirectResponse;
use FOS\UserBundle\Controller\RegistrationController as BaseController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class RegistrationController extends BaseController
{
/**
* Receive the confirmation token from user email provider, login the user
*/
public function confirmAction(Request $request, $token)
{
$userManager = $this->container->get('fos_user.user_manager');
$user = $userManager->findUserByConfirmationToken($token);
if (null === $user) {
/* ************************************
*
* User with token not found. Do whatever you want here
*
* e.g. redirect to login:
*
* return new RedirectResponse($this->container->get('router')->generate('fos_user_security_login'));
*
**************************************/
}
else{
// Token found. Letting the FOSUserBundle's action handle the confirmation
return parent::confirmAction($request, $token);
}
}
}
您需要將'FOSUserBundle'作爲應用程序包的父級,[請參閱此處](http://symfony.com/doc/master/bundles/FOSUserBundle/overriding_controllers.html) – IROEGBU 2017-09-13 22:51:39
有了這個同樣的問題,尋找解決的辦法。愚蠢的用戶沒有範圍雙擊一切! – gezpage 2013-05-28 11:08:25
它應該被處理,但事實並非如此。雙擊重置密碼連接時,同樣的事情,密碼請求間隔到期後。唯一對我有用的是'重寫'路由到fosuser:確認操作,以便路由到我寫的操作。基本覆蓋fos用戶捆綁控制器的一部分。在我的行動中,我檢查確認散列,如果存在,我轉發給fosuserbundle:註冊:確認。如果沒有 - 我回應一些消息。我可以稍後提供一些代碼。 – tiriana 2013-08-21 19:24:16