I am using grails 4.0.3 and I am trying to logout a user programmatically. I search for this but all the solutions that I found are for grails 2 and are not working for grails 4.
Like - force logout for authenticated user using spring security plugin
Does anyone have any idea how to invalidate a user session?
In a controller you can invoke
session.invalidate()
.If you want to access the session from some other context, you could have that class implement the
grails.web.api.ServletAttributes
trait, which will provide thesession
property to that class and thensession.invalidate()
may be called from there.