Improve conditional check.
@@ -892,11 +892,10 @@ public class ApplicationMgtUtil {
AbstractUserStoreManager userStoreManager =
(AbstractUserStoreManager) ApplicationManagementServiceComponentHolder.getInstance()
.getRealmService().getTenantUserRealm(tenantId).getUserStoreManager();
- if (username != null && userStoreManager.isExistingUser(username)) {
+ if (username != null) {
+ if (userStoreManager.isExistingUser(username)) {
user = new User(userStoreManager.getUser(null, username));
- } else if (userId != null && userStoreManager.isExistingUserWithID(userId)) {
- user = new User(userStoreManager.getUser(userId, null));
- } else if (username != null && userStoreManager.isExistingUserWithID(username)) {
+ } else if (userStoreManager.isExistingUserWithID(username)) {
/*
For federated admin user flow, sometimes their user id will be sent to federated tenant as name.
Thus need to fetch user details using username as user id from their original
@@ -904,6 +903,9 @@ public class ApplicationMgtUtil {
*/
user = new User(userStoreManager.getUser(username, null));
}
+ } else if (userId != null && userStoreManager.isExistingUserWithID(userId)) {
+ user = new User(userStoreManager.getUser(userId, null));
+ }
} catch (UserStoreException e) {
throw new IdentityApplicationManagementException("Error finding user in tenant.", e);
}
