简体   繁体   中英

Symfony2. Forwarding to login_check in isn't interceipted

I would like to authentificate user after its registration.

So registrationAction is:

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.

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 .

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

What is your opinion?

Trying to perform a redirect with POST is not a good idea. Here's why: 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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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