From 36cc298b324183693300f3a40f4bd2a39d6a97a6 Mon Sep 17 00:00:00 2001 From: mposolda Date: Thu, 9 Oct 2014 11:37:42 +0200 Subject: [PATCH] Fix mongo to pass with testsuite --- .../models/sessions/mongo/MongoUserSessionProvider.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/model/sessions-mongo/src/main/java/org/keycloak/models/sessions/mongo/MongoUserSessionProvider.java b/model/sessions-mongo/src/main/java/org/keycloak/models/sessions/mongo/MongoUserSessionProvider.java index fe3bb2ded9..e2e9478337 100755 --- a/model/sessions-mongo/src/main/java/org/keycloak/models/sessions/mongo/MongoUserSessionProvider.java +++ b/model/sessions-mongo/src/main/java/org/keycloak/models/sessions/mongo/MongoUserSessionProvider.java @@ -128,6 +128,7 @@ public class MongoUserSessionProvider implements UserSessionProvider { public List getUserSessions(RealmModel realm, ClientModel client, int firstResult, int maxResults) { DBObject query = new QueryBuilder() .and("clientId").is(client.getId()) + .and("sessionId").notEquals(null) .get(); DBObject sort = new BasicDBObject("timestamp", 1).append("id", 1); @@ -142,7 +143,11 @@ public class MongoUserSessionProvider implements UserSessionProvider { @Override public int getActiveUserSessions(RealmModel realm, ClientModel client) { - return getUserSessions(realm, client).size(); + DBObject query = new QueryBuilder() + .and("clientId").is(client.getId()) + .and("sessionId").notEquals(null) + .get(); + return mongoStore.countEntities(MongoClientSessionEntity.class, query, invocationContext); } @Override