fix(api): allow logout with user anonymousUser (#2764)

This commit is contained in:
James Ward
2026-09-26 13:20:22 -04:00
committed by GitHub
parent 3707c97d4e
commit 82f2f4f557
2 changed files with 1 additions and 2 deletions
@@ -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"));
@@ -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;
}