PUGX / PUGXMultiUserBundle

An extension for FOSUserBundle to handle users of different types. Compatible with Doctrine ORM.
163 stars 96 forks source link

Flash messages after redirection #123

Open pjam opened 7 years ago

pjam commented 7 years ago

Hi.

In my app, after a user changes his password, I redirect him to his profile form page. Doing so, the flash message with the password change success is getting eaten in the way, as it does not show.

garak commented 7 years ago

How do you perform the redirect?

pjam commented 7 years ago

I use a listener for the CHANGE_PASSWORD_SUCCESS event setting the response with a RedirectResponse for the profile route. I found out that the flashes get lost after $result = $this->controller->editAction($this->getRequest()); in the edit method of the Profile Manager.

My workaround is saving the existing flashes before that call: $flashes = $this->getRequest()->getSession()->getFlashBag()->all();

and then setting them back afterwards with $this->getRequest()->getSession()->getFlashBag()->setAll($flashes);