Commit c51bc65a by linxu

fix(logout): improve REST logout success handler and update gitignore

parent 8e04c9f4
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
.settings .settings
.springBeans .springBeans
.sts4-cache .sts4-cache
.DS_Store
### IntelliJ IDEA ### ### IntelliJ IDEA ###
.idea .idea
......
package com.keymobile.sso.conf; package com.keymobile.sso.conf;
import com.keymobile.sso.logging.LogConstants;
import com.keymobile.sso.logging.LogManager;
import jakarta.servlet.ServletException; import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
...@@ -16,6 +18,10 @@ public class RESTLogoutSuccessHandler implements LogoutSuccessHandler { ...@@ -16,6 +18,10 @@ public class RESTLogoutSuccessHandler implements LogoutSuccessHandler {
@Override @Override
public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException { public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
if (authentication != null && authentication.getName() != null) {
LogManager.logInfo(LogConstants.CTX_AUDIT, "User logged out: " + authentication.getName());
}
request.getSession().invalidate();
response.setStatus(HttpStatus.OK.value()); response.setStatus(HttpStatus.OK.value());
response.getWriter().flush(); response.getWriter().flush();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment