Search code examples
grailsgrails-2.0grails-plugin

grails spring security redirect after logout


I'm using grails spring security and want to redirect user to some url just after logout. What I've discovered so far is that there is a special property for that called 'logout.afterLogoutUrl' and that grails.plugin.springsecurity.logout.postOnly should be set to false. So in my Config.groovy I have:

grails.plugin.springsecurity.logout.postOnly = false
logout.afterLogoutUrl = "/"

my logout button looks like:

    <sec:ifLoggedIn>
        <g:remoteLink class="logout buttons" controller="logout"><g:message code="btn.logout"
                                                               default="Loading&hellip;"/></g:remoteLink>
    </sec:ifLoggedIn>

When I click on logout button the following sequence of requests appears:

  1. /logout/index
  2. /j_spring_security_logout
  3. /
  4. /login/authAjax

and from the last one I get 'Status Code:401 Unauthorized' but user still sees the page from where I clicked logout button. Does anyone know how to handle this situation? Thank you very much!


Solution

  • I noticed that I use wrong property name for logout url. I changed its name to grails.plugin.springsecurity.logout.afterLogoutUrl