A self hosted chat application with end-to-end encrypted messaging.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
949 B

  1. package org.ros.chatto.logged;
  2. import java.io.IOException;
  3. import javax.servlet.http.HttpServletRequest;
  4. import javax.servlet.http.HttpServletResponse;
  5. import javax.servlet.http.HttpSession;
  6. import org.springframework.security.core.Authentication;
  7. import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
  8. import org.springframework.stereotype.Component;
  9. @Component("myAuthenticationSuccessHandler")
  10. public class UserSessionLoggingLoginSuccessHandler
  11. implements AuthenticationSuccessHandler {
  12. @Override
  13. public void onAuthenticationSuccess(HttpServletRequest request,
  14. HttpServletResponse response, Authentication authentication)
  15. throws IOException {
  16. HttpSession session = request.getSession(false);
  17. if (session != null) {
  18. UserLoggingSessionListener user = new UserLoggingSessionListener(
  19. authentication.getName());
  20. session.setAttribute("user", user);
  21. }
  22. response.sendRedirect("/chat");
  23. }
  24. }