User search returned users for all realms

This commit is contained in:
Stian Thorgersen 2013-11-26 13:53:57 +00:00
parent 874727f927
commit f933ffba3f
2 changed files with 3 additions and 1 deletions

View file

@ -666,7 +666,8 @@ public class RealmAdapter implements RealmModel {
@Override
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() + "%");
List<UserEntity> results = query.getResultList();
List<UserModel> users = new ArrayList<UserModel>();

View file

@ -303,6 +303,7 @@ public class AdapterTest extends AbstractKeycloakTest {
}
RealmManager adapter = getRealmManager();
adapter.createRealm("other").addUser("bburke");
{
List<UserModel> userModels = adapter.searchUsers("total junk query", realmModel);