Fix search for users by attribute on mongo
This commit is contained in:
parent
59d66dd20e
commit
d905ce12e3
1 changed files with 5 additions and 5 deletions
|
@ -193,16 +193,16 @@ public class MongoUserProvider implements UserProvider {
|
||||||
.and("realmId").is(realm.getId());
|
.and("realmId").is(realm.getId());
|
||||||
|
|
||||||
for (Map.Entry<String, String> entry : attributes.entrySet()) {
|
for (Map.Entry<String, String> entry : attributes.entrySet()) {
|
||||||
if (entry.getKey().equals(UserModel.USERNAME)) {
|
if (entry.getKey().equalsIgnoreCase(UserModel.USERNAME)) {
|
||||||
queryBuilder.and("username").regex(Pattern.compile("(?i:" + entry.getValue() + "$)"));
|
queryBuilder.and(UserModel.USERNAME).regex(Pattern.compile(".*" + entry.getValue() + ".*", Pattern.CASE_INSENSITIVE));
|
||||||
} else if (entry.getKey().equalsIgnoreCase(UserModel.FIRST_NAME)) {
|
} else if (entry.getKey().equalsIgnoreCase(UserModel.FIRST_NAME)) {
|
||||||
queryBuilder.and(UserModel.FIRST_NAME).regex(Pattern.compile("(?i:" + entry.getValue() + "$)"));
|
queryBuilder.and(UserModel.FIRST_NAME).regex(Pattern.compile(".*" + entry.getValue() + ".*", Pattern.CASE_INSENSITIVE));
|
||||||
|
|
||||||
} else if (entry.getKey().equalsIgnoreCase(UserModel.LAST_NAME)) {
|
} else if (entry.getKey().equalsIgnoreCase(UserModel.LAST_NAME)) {
|
||||||
queryBuilder.and(UserModel.LAST_NAME).regex(Pattern.compile("(?i:" + entry.getValue() + "$)"));
|
queryBuilder.and(UserModel.LAST_NAME).regex(Pattern.compile(".*" + entry.getValue() + ".*", Pattern.CASE_INSENSITIVE));
|
||||||
|
|
||||||
} else if (entry.getKey().equalsIgnoreCase(UserModel.EMAIL)) {
|
} else if (entry.getKey().equalsIgnoreCase(UserModel.EMAIL)) {
|
||||||
queryBuilder.and(UserModel.EMAIL).regex(Pattern.compile("(?i:" + entry.getValue() + "$)"));
|
queryBuilder.and(UserModel.EMAIL).regex(Pattern.compile(".*" + entry.getValue() + ".*", Pattern.CASE_INSENSITIVE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue