-
Notifications
You must be signed in to change notification settings - Fork 348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
可以实现 logout吗? #7
Comments
也可以指定AppLogoutSuccessHandler +@Slf4j
public class AppLogoutSuccessHandler implements LogoutSuccessHandler {
@Autowired
private SessionRegistry sessionRegistry;
@Override
public void onLogoutSuccess(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Authentication authentication) throws IOException, ServletException {
if (authentication != null && authentication.getDetails() != null) {
removeAuthSession(authentication, sessionRegistry);
httpServletRequest.getSession().invalidate();
httpServletResponse.sendRedirect("login.html?logout");
}
}
private void removeAuthSession(Authentication authentication, SessionRegistry sessionRegistry) {
List<SessionInformation> sessions = sessionRegistry.getAllSessions(authentication.getPrincipal(), false);
if (sessions.size() > 0) { // there is only 1 session allowed
log.debug("removing session {} from registry", sessions.get(0).getSessionId());
sessionRegistry.removeSessionInformation(sessions.get(0).getSessionId());
}
}
} |
谢谢哈!!! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
可以实现 logout吗? 就是 使之前的authorization失效!!!
The text was updated successfully, but these errors were encountered: