remove call to currentUserService to prevent 401 on not logged in users
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good

This commit is contained in:
2026-02-02 10:39:07 +01:00
parent c43101e5dc
commit 4fe86b6845
3 changed files with 1 additions and 8 deletions
@@ -37,12 +37,6 @@ class RoutingAlternativeController {
public ResponseEntity<List<RouteDTO>> requestAlternativeRoutes(@Valid @RequestBody RoutingAlternativeRequestDTO routingAlternativeRequestDTO) {
try {
if (currentUserService.isAuthenticated()) {
logger.info("Authenticaed user is making request: " + currentUserService.get().getEmail());
} else {
logger.info("Unauthenticated user is making request.");
}
if (routingAlternativeRequestDTO.getRoutingPreferencesDTO() == null) {
// This automatically uses default preferences for unauthenticated users
routingAlternativeRequestDTO.setRoutingPreferencesDTO(routingPreferencesService.getRoutingPreferencesForCurrentUser());
@@ -41,8 +41,6 @@ import static org.springframework.security.config.Customizer.withDefaults;
public class SecurityConfiguration {
private static final String[] AUTH_WHITELIST = {
"/routing/alternative/request",
"/routing/directions/request",
"/api/v1/auth/**",
"/v3/api-docs/**",
"/v3/api-docs.yaml",
@@ -33,6 +33,7 @@ public class CurrentUserService {
}
public boolean isAuthenticated() {
// TODO request with auth no auth really result in not authenticated?
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
return auth != null && auth.isAuthenticated();
}