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?
            Asked
            
        
        
            Active
            
        
            Viewed 412 times
        
    1 Answers
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
 
- 
                    Also please check the state for your *session* object and call *session.invalidate()* if need – Eugene Hoza Oct 14 '19 at 13:02