When Organization feature is enabled UserAdapter.getGroupsCount() returns wrong result

Closes #32460

Signed-off-by: vramik <vramik@redhat.com>
This commit is contained in:
vramik 2024-08-28 18:24:05 +02:00 committed by Alexander Schwartz
parent c821ecb908
commit 37f42430e6

View file

@ -399,10 +399,10 @@ public class UserAdapter implements UserModel, JpaModel<UserEntity> {
public long getGroupsCount() {
Long result = createCountGroupsQuery().getSingleResult();
if (Profile.isFeatureEnabled(Feature.ORGANIZATION)) {
OrganizationProvider provider = session.getProvider(OrganizationProvider.class);
if (result > 0 && provider.getByMember(this) != null) {
if (result > 0) {
// remove from the count the organization group membership
result--;
OrganizationProvider provider = session.getProvider(OrganizationProvider.class);
result -= provider.getByMember(this).count();
}
}
return result;