Announcement Announcement Module
Collapse
No announcement yet.
Why is redirecting after logout so obfuscated? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Why is redirecting after logout so obfuscated?

    I merely wish to redirect a user in production to a location other than "/". Why is that so difficult and involved in Grails? According to the documentation I need to create a bean for a custom logout handler in resources.groovy, register that handler with spring security handler names in config.groovy, add a handler that implements the Logout Handler interface , create my new class in src/groovy for my custom event handler. Someone has tried to create an example here showing how the redirect logout handler might manually call each of the logout filters before redirecting (which seems to be a mistake). In my handler I would pull a configuration variable to tell me (production vs development) where to redirect after logout.

    I guess my question really is--were the architects on crack to disable setting the default logout url? This should be brain-dead simple and not requiring grinding through old/new documents and comments in order to implement a simple redirect after successful logout.

    Well, nothing like adding multiple lines of code in multiple files to implement a simple redirect to increase my productivity.

    ----
    It turns out that Burt (may he always work on Grails) provided a clean example of how to redirect after logout here using an override for SimpleUrlLogoutSuccessHandler. The only gotcha I encountered is if you use a grails environment field for the url you need to inject this into the bean like so:

    // custom logout redirect
    logoutSuccessHandler(CustomLogoutSuccessHandler) {
    redirectStrategy = ref('redirectStrategy')
    grailsApplication = ref('grailsApplication')
    }
    Still is pretty silly and a waste of time but at least it works. Burt's example shows how one can readily change the redirect url dynamically based on the user as well.
    Last edited by MikeTempleman; May 23rd, 2013, 12:23 PM. Reason: Worked out answer
Working...
X