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.开发者_如何学C Any ideas how to make it work or maybe some workarounds?
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
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
andfadeutAndRemove
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
精彩评论