Changed roles in Activite and Session endpoints

This commit is contained in:
Alexis Leboeuf
2026-01-08 11:36:54 +01:00
parent 824d5f4388
commit 25bae7652e
3 changed files with 12 additions and 12 deletions

View File

@@ -7,7 +7,7 @@ import java.util.List;
@Data
public class SessionDTO {
private Integer id;
private String name;
private Boolean isRecurrent;
private LocalDateTime creneau;

View File

@@ -46,7 +46,7 @@ public class ActiviteResource {
})
@PostMapping("/create")
@ResponseBody
@PreAuthorize("hasRole('Coach')")
@PreAuthorize("hasRole('coach')")
public ResponseEntity<String> create(@RequestBody ActiviteDTO dto) {
try {
@@ -69,7 +69,7 @@ public class ActiviteResource {
})
@DeleteMapping("/delete/{id}")
@ResponseBody
@PreAuthorize("hasRole('Coach')")
@PreAuthorize("hasRole('coach')")
public ResponseEntity<String> delete(@PathVariable("id") int id) {
try {
Activite activite = activiteDAO.findById(id).get();
@@ -89,7 +89,7 @@ public class ActiviteResource {
})
@PostMapping("/update/{id}")
@ResponseBody
@PreAuthorize("hasRole('Coach')")
@PreAuthorize("hasRole('coach')")
public ResponseEntity<String> modifyById(@PathVariable("id") int id, @RequestBody ActiviteDTO dto) {
try {
Session session = sessionDAO.findById(dto.getSessionId()).get();
@@ -114,7 +114,7 @@ public class ActiviteResource {
schema = @Schema(implementation = ActiviteDTO.class)))
})
@GetMapping("/{id}")
@PreAuthorize("hasRole('Coach') or hasRole('Athlete')")
@PreAuthorize("hasRole('coach') or hasRole('athlete')")
@ResponseBody
public ResponseEntity<ActiviteDTO> getActivityById(@PathVariable("id") int id) {
try {
@@ -133,7 +133,7 @@ public class ActiviteResource {
schema = @Schema(implementation = ActiviteDTO.class)))
})
@GetMapping("/all")
@PreAuthorize("hasRole('Coach') or hasRole('Athlete')")
@PreAuthorize("hasRole('coach') or hasRole('athlete')")
@ResponseBody
public ResponseEntity<List<ActiviteDTO>> getAllActivity() {
try {
@@ -153,7 +153,7 @@ public class ActiviteResource {
schema = @Schema(implementation = ActiviteDTO.class)))
})
@GetMapping("/theme/{theme}")
@PreAuthorize("hasRole('Coach') or hasRole('Athlete')")
@PreAuthorize("hasRole('coach') or hasRole('athlete')")
@ResponseBody
public ResponseEntity<List<ActiviteDTO>> getActivityByTheme(@PathVariable("theme") String theme) {
try {

View File

@@ -40,7 +40,7 @@ public class SessionResource {
@PostMapping("/create")
@ResponseBody
@PreAuthorize("hasRole('Coach')")
@PreAuthorize("hasRole('coach')")
public ResponseEntity<?> create(@RequestBody SessionDTO dto) {
try {
Session session = maptoEntity(dto);
@@ -53,7 +53,7 @@ public class SessionResource {
}
@GetMapping("/all")
@PreAuthorize("hasRole('Coach') or hasRole('Athlete')")
@PreAuthorize("hasRole('coach') or hasRole('athlete')")
public ResponseEntity<List<SessionDTO>> getAll() {
List<Session> sessions = sessionDAO.findAll();
List<SessionDTO> dtos = new ArrayList<>();
@@ -64,7 +64,7 @@ public class SessionResource {
}
@GetMapping("/{id}")
@PreAuthorize("hasRole('Coach') or hasRole('Athlete')")
@PreAuthorize("hasRole('coach') or hasRole('athlete')")
public ResponseEntity<?> getById(@PathVariable Integer id) {
try {
Session session = sessionDAO.findById(id).orElseThrow();
@@ -76,7 +76,7 @@ public class SessionResource {
@DeleteMapping("/delete/{id}")
@ResponseBody
@PreAuthorize("hasRole('Coach')")
@PreAuthorize("hasRole('coach')")
public ResponseEntity<String> delete(@PathVariable("id") int id) {
try {
Session session = sessionDAO.findById(id).get();
@@ -88,7 +88,7 @@ public class SessionResource {
}
@PutMapping("/update/{id}")
@PreAuthorize("hasRole('Coach')")
@PreAuthorize("hasRole('coach')")
public ResponseEntity<Void> updateSession(@PathVariable Integer id, @RequestBody SessionDTO dto) {
Session session = sessionDAO.findById(id).orElseThrow(() -> new ResponseStatusException(
HttpStatus.NOT_FOUND, "Session not found with id " + id));