Skip to content

Commit

Permalink
fix: don't use getAllPrincipals
Browse files Browse the repository at this point in the history
Signed-off-by: Morten Svanaes <[email protected]>
  • Loading branch information
netroms committed Jan 17, 2025
1 parent 472324d commit 69f0f1d
Showing 1 changed file with 5 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1076,22 +1076,15 @@ public List<UserLookup> getLinkedUserAccounts(@Nonnull User actingUser) {
}

@Override
public void invalidateUserSessions(String userUid) {
UserDetails principal = getPrincipalFromSessionRegistry(userUid);
if (principal != null) {
List<SessionInformation> allSessions = sessionRegistry.getAllSessions(principal, false);
public void invalidateUserSessions(String username) {
User user = getUserByUsername(username);
UserDetails userDetails = createUserDetails(user);
if (userDetails != null) {
List<SessionInformation> allSessions = sessionRegistry.getAllSessions(userDetails, false);
allSessions.forEach(SessionInformation::expireNow);
}
}

private UserDetails getPrincipalFromSessionRegistry(String userUid) {
return sessionRegistry.getAllPrincipals().stream()
.map(UserDetails.class::cast)
.filter(principal -> userUid.equals(principal.getUid()))
.findFirst()
.orElse(null);
}

@Override
@Transactional(readOnly = true)
public ErrorCode validateInvite(User user) {
Expand Down

0 comments on commit 69f0f1d

Please sign in to comment.