1

Is there a logout method for Spring Security that I can use in a controller? Or is there a way to logout by clearing the cache and refreshing?

doelleri
  • 19,232
  • 5
  • 61
  • 65
ken
  • 29
  • 3

1 Answers1

1

Grails controllers have a request object available in them that is an instance of HttpServletRequest. You can use this to log the current user out by calling the logout() method on it.

class TestController {

    def logMeOut() {
        request.logout() // Logout current user
        redirect(controller: 'home', action: 'index') // Redirect to the home page
    }
}

Spring Security adds a little more information on the logout method.

doelleri
  • 19,232
  • 5
  • 61
  • 65