5
votes

I have an action which allows user to change his password. When everything goes well, I'd like to logout him and display a message that everything went well and now he needs to login using his new password.

I tried:

flash.message = "You may now login with your new password"
redirect (controller: 'logout')

Thing is that Logout controller makes redirection to:

redirect uri: SpringSecurityUtils.securityConfig.logout.filterProcessesUrl

And my flash message is no longer there when user is definitely logged out and back on main page. Any ideas how to make it work or maybe some workarounds?

2
Just curious, why are you logging them out? If I were using the system, I wouldn't expect to be logged out after changing my password. - Rob Hruska
No special reason. I'm just thinking it's better that way ;) - jjczopek

2 Answers

3
votes

LogoutController is just there as a convenience. There's a filter that intercepts its redirect and performs the logout logic, so you can just redirect directly to that:

flash.message = "You may now login with your new password"
redirect uri: SpringSecurityUtils.securityConfig.logout.filterProcessesUrl
0
votes

Here is a work-around for this problem:

  • Invalidate the session
  • Setup the flash message
  • Redirect to an empty page
  • Then we run jQuery delay and fadeutAndRemove on the flash message div which then redirects to the logout controller

It's not perfect but it gets the message to the user and takes them back to the login page