![](/img/trans.png)
[英]how to fix /login_check “this page isn't working” on hosted symfony 3.4 project
[英]Symfony2. Forwarding to login_check in isn't interceipted
我想在注冊后驗證用戶身份。
所以registrationAction是:
public function registrationAction(Request $request) {
//Creating user...
return $this->forward('AcmeFrontBundle:Mobile:securityCheck', array(
'_username' => $customer->getEmail(),
'_password' => 'pwd',
));
}
問題在於,Symfony安全系統不會攔截該重定向,而是直接執行securityCheckAction ,它自然是空的。
重定向以這種方式工作:
return $this->redirect($this->generateUrl('mobile_login_check') . "?_username=" . $customer->getEmail() . "&_password=pass");
轉發是可取的,因為我想將POST請求用於registrationAction和securityCheckAction 。
有任何想法嗎?
另一方面,也許最好由我自己對用戶進行身份驗證? 就像這里描述的一樣: http : //symfony.com/doc/current/cookbook/testing/simulating_authentication.html
你有什么意見?
嘗試使用POST執行重定向不是一個好主意。 原因如下: https : //softwareengineering.stackexchange.com/questions/99894/why-doesnt-http-have-post-redirect
最好的方法是創建令牌並發出登錄事件: 如何以編程方式登錄/驗證用戶?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.