Grails redirection after logout

9 Jun

spring security core: 1.0.1

In DefaultSecurityConfig.groovy there is a ‘logout.afterLogoutUrl’ property that can be replaced in the Config.groovy. The use of that property (as it name described) : after logout it will be redirected to that url. I was thinking how if i want to redirected to specified url based on user’s role (dynamic url when logout) because in the project i’m in, i must redirect it to either this login page or that login page since there are 2 login page. After several googling (thanks to the google again), finally i found how to do it. we can use:

redirect uri: SpringSecurityUtils.securityConfig.logout.filterProcessesUrl + “?spring-security-redirect=/login1Page”

the code above will redirect us to the login1Page after we logout and if we want to pass parameter to that login1Page we can use:

redirect uri: SpringSecurityUtils.securityConfig.logout.filterProcessesUrl + “?spring-security-redirect=/login1Page?lang=en”

3 Responses to “Grails redirection after logout”

  1. thmarxorsten October 6, 2011 at 5:32 pm #

    you just made my day with this post. I was searching for hours to solve this redirect problem after logout.

    thanx for this post.

  2. Isaac November 3, 2014 at 11:56 am #

    thanx man, i was stuck for two days before i stumble to your soln. Now it work like a charm…thank you

Leave a comment