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