diff --git a/resq/backend/resq/pom.xml b/resq/backend/resq/pom.xml index 7eebeb48..990bc3e6 100644 --- a/resq/backend/resq/pom.xml +++ b/resq/backend/resq/pom.xml @@ -82,6 +82,14 @@ commons-beanutils 1.9.4 + + diff --git a/resq/backend/resq/src/main/java/com/groupa1/resq/converter/ProfileConverter.java b/resq/backend/resq/src/main/java/com/groupa1/resq/converter/ProfileConverter.java index 339672ad..89463780 100644 --- a/resq/backend/resq/src/main/java/com/groupa1/resq/converter/ProfileConverter.java +++ b/resq/backend/resq/src/main/java/com/groupa1/resq/converter/ProfileConverter.java @@ -2,6 +2,7 @@ import com.groupa1.resq.dto.ProfileDto; import com.groupa1.resq.entity.UserProfile; +import com.groupa1.resq.exception.EntityNotFoundException; import org.modelmapper.ModelMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -13,6 +14,9 @@ public class ProfileConverter { ModelMapper modelMapper; public ProfileDto convertToDto(UserProfile userProfile) { + if(userProfile == null) { + throw new EntityNotFoundException("User profile not found"); + } ProfileDto profileDto = modelMapper.map(userProfile, ProfileDto.class); return profileDto; } diff --git a/resq/backend/resq/src/main/java/com/groupa1/resq/entity/User.java b/resq/backend/resq/src/main/java/com/groupa1/resq/entity/User.java index 8f523e81..fd5f2929 100644 --- a/resq/backend/resq/src/main/java/com/groupa1/resq/entity/User.java +++ b/resq/backend/resq/src/main/java/com/groupa1/resq/entity/User.java @@ -7,7 +7,6 @@ import jakarta.validation.constraints.Size; import lombok.Data; import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; import lombok.ToString; import java.util.HashSet; @@ -20,7 +19,7 @@ }) @Data @EqualsAndHashCode(callSuper = true, exclude = {"userProfile", "requests", "needs", "resourcesReceived","resourcesSent", "tasksAssigned", "tasksAssignedTo", "feedbacks", "actions", "infos", "notifications"}) -@ToString(callSuper = true) +@ToString(callSuper = true, exclude = {"userProfile", "requests", "needs", "resourcesReceived","resourcesSent", "tasksAssigned", "tasksAssignedTo", "feedbacks", "actions", "infos", "notifications"}) public class User extends BaseEntity { @NotBlank diff --git a/resq/backend/resq/src/main/java/com/groupa1/resq/security/WebSecurityConfig.java b/resq/backend/resq/src/main/java/com/groupa1/resq/security/WebSecurityConfig.java index 0deeb2b4..9c18a5cb 100644 --- a/resq/backend/resq/src/main/java/com/groupa1/resq/security/WebSecurityConfig.java +++ b/resq/backend/resq/src/main/java/com/groupa1/resq/security/WebSecurityConfig.java @@ -62,6 +62,7 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { .sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) .authorizeHttpRequests(auth -> auth.requestMatchers("/auth/**").permitAll() + .requestMatchers("/error").permitAll() .requestMatchers("/v3/api-docs/**", "/swagger-ui/**", "/swagger-ui.html").permitAll() .anyRequest().authenticated() );