开发者

How to programmatically logout in acegi plugin in Grails?

开发者 https://www.devze.com 2022-12-29 03:25 出处:网络
Is there a similar logic for logout using this login code: // login account def autht = new AuthToken(username, password)

Is there a similar logic for logout using this login code:

// login account
def autht = new AuthToken(username, password)
def authtoken = daoAuthenticationProvider.authenticate(autht)
SecurityContextHolder.context.authentication = 开发者_JS百科authtoken

I checked LogoutController and this is the only logic for logout:

redirect(uri: '/j_spring_security_logout')

Any idea? Thanks


You would need to invalidate the session:

session.invalidate()

and remove the authentication:

SecurityContextHolder.clearContext()

You also need to remove their remember-me cookie if that's supported. Add a dependency injection for rememberMeServices ("def rememberMeServices") and call

rememberMeServices.logout request, response, null
0

精彩评论

暂无评论...
验证码 换一张
取 消