User search returned users for all realms
This commit is contained in:
parent
874727f927
commit
f933ffba3f
2 changed files with 3 additions and 1 deletions
|
@ -666,7 +666,8 @@ public class RealmAdapter implements RealmModel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<UserModel> searchForUser(String search) {
|
public List<UserModel> searchForUser(String search) {
|
||||||
TypedQuery<UserEntity> query = em.createQuery("select u from UserEntity u where lower(u.loginName) like :search or lower(concat(u.firstName, ' ', u.lastName)) like :search or u.email like :search", UserEntity.class);
|
TypedQuery<UserEntity> query = em.createQuery("select u from UserEntity u where u.realm = :realm and lower(u.loginName) like :search or lower(concat(u.firstName, ' ', u.lastName)) like :search or u.email like :search", UserEntity.class);
|
||||||
|
query.setParameter("realm", realm);
|
||||||
query.setParameter("search", "%" + search.toLowerCase() + "%");
|
query.setParameter("search", "%" + search.toLowerCase() + "%");
|
||||||
List<UserEntity> results = query.getResultList();
|
List<UserEntity> results = query.getResultList();
|
||||||
List<UserModel> users = new ArrayList<UserModel>();
|
List<UserModel> users = new ArrayList<UserModel>();
|
||||||
|
|
|
@ -303,6 +303,7 @@ public class AdapterTest extends AbstractKeycloakTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
RealmManager adapter = getRealmManager();
|
RealmManager adapter = getRealmManager();
|
||||||
|
adapter.createRealm("other").addUser("bburke");
|
||||||
|
|
||||||
{
|
{
|
||||||
List<UserModel> userModels = adapter.searchUsers("total junk query", realmModel);
|
List<UserModel> userModels = adapter.searchUsers("total junk query", realmModel);
|
||||||
|
|
Loading…
Reference in a new issue