athlete test
This commit is contained in:
@@ -26,7 +26,7 @@ public class WebSecurityConfig {
|
|||||||
.cors(cors -> cors.configurationSource(corsConfigurationSource()))
|
.cors(cors -> cors.configurationSource(corsConfigurationSource()))
|
||||||
.csrf(csrf -> csrf.disable())
|
.csrf(csrf -> csrf.disable())
|
||||||
.authorizeHttpRequests(auth -> auth
|
.authorizeHttpRequests(auth -> auth
|
||||||
.requestMatchers(HttpMethod.OPTIONS, "/", "/public", "/coach/**").permitAll() // allow coach endpoints
|
.requestMatchers(HttpMethod.OPTIONS, "/", "/public", "/coach/**","/athlete/**").permitAll() // allow coach endpoints
|
||||||
.requestMatchers("/admin/**").hasRole("admin")
|
.requestMatchers("/admin/**").hasRole("admin")
|
||||||
.requestMatchers("/user/**").hasRole("user")
|
.requestMatchers("/user/**").hasRole("user")
|
||||||
.anyRequest().authenticated())
|
.anyRequest().authenticated())
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
|||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/athlete")
|
@RequestMapping("/athlete")
|
||||||
|
@CrossOrigin(origins = "http://localhost:3000")
|
||||||
public class AthleteResource {
|
public class AthleteResource {
|
||||||
@Autowired
|
@Autowired
|
||||||
private AthleteDAO athleteDAO;
|
private AthleteDAO athleteDAO;
|
||||||
@@ -44,6 +45,7 @@ public class AthleteResource {
|
|||||||
@ApiResponse(responseCode = "200", description = "Renvoie l'athlète créé", content = @Content(mediaType = "application/json", schema = @Schema(implementation = AthleteDTO.class)))
|
@ApiResponse(responseCode = "200", description = "Renvoie l'athlète créé", content = @Content(mediaType = "application/json", schema = @Schema(implementation = AthleteDTO.class)))
|
||||||
})
|
})
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
|
@PreAuthorize("hasRole('Admin') or hasRole('Coach') or hasRole('Athlete')")
|
||||||
public ResponseEntity<AthleteDTO> create(@RequestBody AthleteDTO dto) {
|
public ResponseEntity<AthleteDTO> create(@RequestBody AthleteDTO dto) {
|
||||||
Athlete athlete = mapToEntity(dto);
|
Athlete athlete = mapToEntity(dto);
|
||||||
athleteDAO.save(athlete);
|
athleteDAO.save(athlete);
|
||||||
|
|||||||
Reference in New Issue
Block a user