Skip to content

Commit

Permalink
Fix active user sessions not retrieved for b2b users accessing MyAccount
Browse files Browse the repository at this point in the history
  • Loading branch information
sadilchamishka committed Nov 19, 2023
1 parent 87bb2af commit a517150
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.identity.api.user.common.error.APIError;
import org.wso2.carbon.identity.api.user.common.error.ErrorResponse;
import org.wso2.carbon.identity.api.user.common.function.UserToUniqueId;
Expand All @@ -29,6 +30,7 @@
import org.wso2.carbon.identity.application.authentication.framework.exception.UserSessionException;
import org.wso2.carbon.identity.application.authentication.framework.exception.session.mgt.SessionManagementClientException;
import org.wso2.carbon.identity.application.authentication.framework.exception.session.mgt.SessionManagementException;
import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser;
import org.wso2.carbon.identity.application.authentication.framework.model.UserSession;
import org.wso2.carbon.identity.application.authentication.framework.store.UserSessionStore;
import org.wso2.carbon.identity.application.authentication.framework.util.SessionMgtConstants;
Expand All @@ -53,6 +55,7 @@
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

import javax.ws.rs.core.Response;

import static org.wso2.carbon.identity.api.user.common.Constants.ERROR_CODE_DELIMITER;
Expand Down Expand Up @@ -92,7 +95,7 @@ public class SessionManagementService {
public SessionsDTO getSessionsBySessionId(User user, Integer limit, Integer offset, String filter, String sort) {

String userId;
if (isFederatedUser()) {
if (isFederatedUser() && !isOrganizationSsoUser()) {
userId = getFederatedUserIdFromUser(user);
} else {
userId = getUserIdFromUser(user);
Expand Down Expand Up @@ -400,6 +403,12 @@ private boolean isFederatedUser() {
(boolean) IdentityUtil.threadLocalProperties.get().get(IS_FEDERATED_USER);
}

private boolean isOrganizationSsoUser() {

return isFederatedUser() && StringUtils.isNotEmpty(PrivilegedCarbonContext.getThreadLocalCarbonContext()
.getUserResidentOrganizationId());
}

/**
* Get the filter nodes as a list.
*
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@
<version.org.wso2.orbit.javax.xml.bind>2.3.1.wso2v1</version.org.wso2.orbit.javax.xml.bind>
<maven.buildnumber.plugin.version>1.4</maven.buildnumber.plugin.version>
<org.apache.felix.annotations.version>1.2.4</org.apache.felix.annotations.version>
<carbon.kernel.version>4.9.0</carbon.kernel.version>
<carbon.kernel.version>4.9.17</carbon.kernel.version>
<identity.governance.version>1.8.73</identity.governance.version>
<carbon.identity.framework.version>5.25.380</carbon.identity.framework.version>
<carbon.identity.account.association.version>5.3.7</carbon.identity.account.association.version>
Expand Down

0 comments on commit a517150

Please sign in to comment.