![](/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.