简体   繁体   中英

redirect after authentication in zend framework 2

I am trying to implement a control to check if the password is expired whenever a user authenticates. I am using a ListenerAggregateInterface to listen to the ZfcUser event authentication.success .

After I perform my check I am not able to redirect the user to the change password page. How can I do that?

Looking around, usually people have a MvcEvent and so they can use the method getReponse to modify the headers and perform a 302 redirect, or they use redirect functionality available in controllers. In my case I have an AdapterChainEvent and I'm not in a controller.

Any hint is highly appreciated

All you would need to do is return a response instance; it doesn't need to be the response instance (although you could inject it into your listener aggregate if you register the aggregate via the service manager).

This will stop event propagation an return the response to the controller . The ZfcUser\\Controller\\UserController will then return this performing the redirect.

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