Skip to content

Commit

Permalink
Iterating over all users with a given brokered user id and filtering …
Browse files Browse the repository at this point in the history
…sessions

Signed-off-by: Pedro Igor <[email protected]>
  • Loading branch information
pedroigor committed Sep 2, 2024
1 parent 44ef081 commit ea37fea
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -373,11 +373,10 @@ protected Stream<UserSessionModel> getUserSessionsStream(RealmModel realm, UserS
attributes.put(UserModel.IDP_USER_ID, idpAliasSessionId[1]);

UserProvider userProvider = session.getProvider(UserProvider.class);
UserModel userModel = userProvider.searchForUserStream(realm, attributes, 0, null).findFirst().orElse(null);
return userModel != null ?
persister.loadUserSessionsStream(realm, userModel, true, 0, null)
.filter(predicate.toModelPredicate()) :
Stream.empty();

return userProvider.searchForUserStream(realm, attributes, 0, null)
.flatMap((Function<UserModel, Stream<UserSessionModel>>) userModel -> persister.loadUserSessionsStream(realm, userModel, true, 0, null))
.filter(predicate.toModelPredicate());
}

throw new ModelException("For offline sessions, only lookup by userId and brokerUserId is supported");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,13 +332,12 @@ public String getId() {
attributes.put(UserModel.IDP_USER_ID, idpAliasSessionId[1]);

UserProvider userProvider = session.getProvider(UserProvider.class);
UserModel userModel = userProvider.searchForUserStream(realm, attributes, 0, null).findFirst().orElse(null);
return userModel != null ?
persister.loadUserSessionsStream(realm, userModel, offline, 0, null)
.filter(predicate.toModelPredicate())
.map(s -> (UserSessionModel) getUserSession(realm, s.getId(), s, offline))
.filter(Objects::nonNull) :
Stream.empty();

return userProvider.searchForUserStream(realm, attributes, 0, null)
.flatMap((Function<UserModel, Stream<UserSessionModel>>) userModel -> persister.loadUserSessionsStream(realm, userModel, offline, 0, null))
.filter(predicate.toModelPredicate())
.map(s -> (UserSessionModel) getUserSession(realm, s.getId(), s, offline))
.filter(Objects::nonNull);
}

if (predicate.getClient() != null) {
Expand Down

0 comments on commit ea37fea

Please sign in to comment.