public void removeUserFromSession(Integer userId, String operator) {
        DefaultWebSecurityManager securityManager = (DefaultWebSecurityManager) SecurityUtils.getSecurityManager();
        DefaultWebSessionManager sessionManager = (DefaultWebSessionManager) securityManager.getSessionManager();
        SessionDAO sessionDAO = sessionManager.getSessionDAO();
        Collection<Session> sessions = sessionDAO.getActiveSessions();
        if (sessions.size() >= 1) {
            UserInfo user = null;
            for (Session onlineSession : sessions) {
                Object attribute = onlineSession.getAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY);
                if (attribute == null) {
                    continue;
                }
                user = (UserInfo) ((SimplePrincipalCollection) attribute).getPrimaryPrincipal();
                if (user == null) {
                    continue;
                }
                if (Objects.equals(user.getId(), userId)) {
                    sessionDAO.delete(onlineSession);
                    LOGGER.info("success remove user from session by id={}, current user={}", user.getId(), operator);
                }
            }
        }
    }
This implementation is just to intercept some error requests and reduce the pressure on the database.
<p/>
This is a memory-based implementation. There is a problem with concurrency security when there are
multiple service nodes because the data in memory cannot be shared.

@param req username login request
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/user/UserServiceImpl.java