简体   繁体   中英

Grails Spring Security Core logout message

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?

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 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

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