简体   繁体   English

Symfony 2。 未拦截转发到login_check in

[英]Symfony2. Forwarding to login_check in isn't interceipted

I would like to authentificate user after its registration. 我想在注册后验证用户身份。

So registrationAction is: 所以registrationAction是:

public function registrationAction(Request $request) {
    //Creating user...

    return $this->forward('AcmeFrontBundle:Mobile:securityCheck', array(
        '_username' => $customer->getEmail(),
        '_password' => 'pwd',
    ));
}

The problem is that Symfony security system doesn't interceipt this redirecting, but executes directly securityCheckAction which is naturally empty. 问题在于,Symfony安全系统不会拦截该重定向,而是直接执行securityCheckAction ,它自然是空的。

Redirection works in that way: 重定向以这种方式工作:

    return $this->redirect($this->generateUrl('mobile_login_check') . "?_username=" . $customer->getEmail() . "&_password=pass");

Forwarding is preferable because I would like to use POST request for registrationAction and securityCheckAction . 转发是可取的,因为我想将POST请求用于registrationActionsecurityCheckAction

Any ideas? 有任何想法吗?

In the other hand maybe it would be better to authentificate user by myself? 另一方面,也许最好由我自己对用户进行身份验证? Just like described here: http://symfony.com/doc/current/cookbook/testing/simulating_authentication.html 就像这里描述的一样: http : //symfony.com/doc/current/cookbook/testing/simulating_authentication.html

What is your opinion? 你有什么意见?

Trying to perform a redirect with POST is not a good idea. 尝试使用POST执行重定向不是一个好主意。 Here's why: https://softwareengineering.stackexchange.com/questions/99894/why-doesnt-http-have-post-redirect 原因如下: https : //softwareengineering.stackexchange.com/questions/99894/why-doesnt-http-have-post-redirect

The best way is to create token & emit login event: How to programmatically login/authenticate a user? 最好的方法是创建令牌并发出登录事件: 如何以编程方式登录/验证用户?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM