Skip to content

Commit

Permalink
fix: Unsearchable disabled users by their email or name - EXO-69348.
Browse files Browse the repository at this point in the history
Before this change, when set user as a disabled user, select disabled filter and search for usera by his name or his email, user isn't displayed in the result list. After this change, user is displayed in the result list.
  • Loading branch information
akhanfir committed Apr 1, 2024
1 parent d59ba0f commit feff9be
Showing 1 changed file with 14 additions and 6 deletions.
Expand Up @@ -664,14 +664,15 @@ public Collection<IdentityObject> findIdentityObject(IdentityStoreInvocationCont
if (criteria != null && criteria.getFilter() != null) {
String attrValue = criteria.getFilter().replace("\\*", "%").replace("*", "%");
String operator = "=";
criteria.getValues().put("email",new String []{attrValue});
if (attrValue.contains("%")) {
operator = "like";
}
if (isAllowNotCaseSensitiveSearch()) {
attrValue = attrValue.toLowerCase();
hqlBuilderConditions.append(" and lower(io.name) " + operator + " :ioName");
hqlBuilderConditions.append(" and ((lower(io.name) " + operator + " :ioName)");
} else {
hqlBuilderConditions.append(" and io.name " + operator + " :ioName");
hqlBuilderConditions.append(" and ((io.name " + operator + " :ioName)");
}
queryParams.put("ioName", attrValue);
}
Expand All @@ -692,8 +693,8 @@ public Collection<IdentityObject> findIdentityObject(IdentityStoreInvocationCont
i++;
String attrTableJoinName = "attrs" + i;
String attrParamName = "attr" + i;
hqlBuilderConditions.append(" and not exists(from io.attributes as " + attrTableJoinName + " where "
+ attrTableJoinName + ".name = :" + attrParamName + ")");
hqlBuilderConditions.append(") and not exists(from io.attributes as " + attrTableJoinName + " where "
+ attrTableJoinName + ".name = :" + attrParamName);
queryParams.put(attrParamName, mappedAttributeName);
/** End eXo customization **/
} else {
Expand Down Expand Up @@ -728,13 +729,20 @@ public Collection<IdentityObject> findIdentityObject(IdentityStoreInvocationCont
* BEGIN CAL-1225: User picker in Participants tab is case
* sensitive
*/
hqlBuilderConditions.append(" and " + attrTableJoinName + ".name = :" + attrParamName);

if ( "email".equals(entry.getKey()) ) {
hqlBuilderConditions.append(" or ( ");
} else {
hqlBuilderConditions.append(" and ( ");
}
hqlBuilderConditions.append(attrTableJoinName + ".name = :" + attrParamName);
if (isAllowNotCaseSensitiveSearch()) {
hqlBuilderConditions.append(" and lower(" + textValuesTableJoinName + ") " + operator + " :"
+ textValueParamName);
} else {
hqlBuilderConditions.append(" and " + textValuesTableJoinName + " " + operator + " :" + textValueParamName);
}
hqlBuilderConditions.append(")");
/*
* END CAL-1225: User picker in Participants tab is case sensitive
*/
Expand All @@ -745,7 +753,7 @@ public Collection<IdentityObject> findIdentityObject(IdentityStoreInvocationCont
}
}
}

hqlBuilderConditions.append(")");
if (criteria != null && criteria.isSorted()) {
if (criteria.isAscending()) {
hqlBuilderConditions.append(" order by io.name asc");
Expand Down

0 comments on commit feff9be

Please sign in to comment.