Skip to content

Commit

Permalink
Merge pull request #479 from bounswe/bugfix/BE-478-backend-null-check…
Browse files Browse the repository at this point in the history
…-and-auth-errors

#478 Null checks added to ProfileConverter class and /error endpoint …
  • Loading branch information
volcaniqueo authored Nov 27, 2023
2 parents d771ecc + a936484 commit 01bdaa3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
8 changes: 8 additions & 0 deletions resq/backend/resq/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@
<artifactId>commons-beanutils</artifactId>
<version>1.9.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.firebase/firebase-admin
<dependency>
<groupId>com.google.firebase</groupId>
<artifactId>firebase-admin</artifactId>
<version>9.2.0</version>
</dependency>
-->

</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
);
Expand Down

0 comments on commit 01bdaa3

Please sign in to comment.