diff --git a/backend/src/main/java/org/booklore/config/security/service/LogoutService.java b/backend/src/main/java/org/booklore/config/security/service/LogoutService.java index 53674ff01..64afbc9b1 100644 --- a/backend/src/main/java/org/booklore/config/security/service/LogoutService.java +++ b/backend/src/main/java/org/booklore/config/security/service/LogoutService.java @@ -52,7 +52,7 @@ public class LogoutService { } private BookLoreUserEntity resolveUser(Authentication auth, String refreshToken) { - if (auth != null && auth.isAuthenticated() && !"anonymousUser".equals(auth.getPrincipal())) { + if (auth != null && auth.isAuthenticated()) { var bookLoreUser = authenticationService.getAuthenticatedUser(); return userRepository.findByUsername(bookLoreUser.getUsername()) .orElseThrow(() -> ApiError.GENERIC_UNAUTHORIZED.createException("User not found")); diff --git a/backend/src/test/java/org/booklore/config/security/service/LogoutServiceTest.java b/backend/src/test/java/org/booklore/config/security/service/LogoutServiceTest.java index 998a9422f..788ce0038 100644 --- a/backend/src/test/java/org/booklore/config/security/service/LogoutServiceTest.java +++ b/backend/src/test/java/org/booklore/config/security/service/LogoutServiceTest.java @@ -274,7 +274,6 @@ class LogoutServiceTest { private Authentication mockAuth() { var auth = mock(Authentication.class); when(auth.isAuthenticated()).thenReturn(true); - when(auth.getPrincipal()).thenReturn("not-anonymous"); return auth; }