Merge pull request #55 from HediMjid/Blandine

comment des authorize sur menus
This commit is contained in:
AlineRinquin 2022-03-11 14:53:00 +01:00 committed by GitHub
commit 7f2dd8d9a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -23,7 +23,7 @@ public class MenuController {
//Récupère les infos d'un menu par son ID //Récupère les infos d'un menu par son ID
@GetMapping(value = "/{id}") @GetMapping(value = "/{id}")
@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')") //@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')")
public ResponseEntity<?> findById(@PathVariable int id){ public ResponseEntity<?> findById(@PathVariable int id){
Optional<Menu> menu = null; Optional<Menu> menu = null;
try try
@ -38,7 +38,7 @@ public class MenuController {
//Récupère les infos des menus par la team ID //Récupère les infos des menus par la team ID
@GetMapping(value = "team/{team_id}") @GetMapping(value = "team/{team_id}")
@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')") //@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')")
public ResponseEntity<?> findByTeamId(@PathVariable int team_id) { public ResponseEntity<?> findByTeamId(@PathVariable int team_id) {
List<Menu> menus = null; List<Menu> menus = null;
try { try {
@ -51,7 +51,7 @@ public class MenuController {
//Ajoute un nouveau menu //Ajoute un nouveau menu
@PostMapping(value="/add/{team_id}", produces="application/json", consumes= "application/json") @PostMapping(value="/add/{team_id}", produces="application/json", consumes= "application/json")
@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')") //@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')")
public ResponseEntity<?> addMenu(@RequestBody Menu menu, @PathVariable Integer team_id){ public ResponseEntity<?> addMenu(@RequestBody Menu menu, @PathVariable Integer team_id){
Menu resultMenu = null; Menu resultMenu = null;
try { try {
@ -68,7 +68,7 @@ public class MenuController {
//Mise a jour d'un menu par son ID //Mise a jour d'un menu par son ID
@PutMapping(value="/update/{team_id}/{id}", produces="application/json", consumes= "application/json") @PutMapping(value="/update/{team_id}/{id}", produces="application/json", consumes= "application/json")
@PreAuthorize("hasRole('ROLE_PARENT')") //@PreAuthorize("hasRole('ROLE_PARENT')")
public ResponseEntity<?> updateMenu(@RequestBody Menu menu, @PathVariable Integer team_id, @PathVariable Integer id) throws Exception { public ResponseEntity<?> updateMenu(@RequestBody Menu menu, @PathVariable Integer team_id, @PathVariable Integer id) throws Exception {
Menu resultMenu = null; Menu resultMenu = null;
try { try {
@ -87,7 +87,7 @@ public class MenuController {
//Efface un menu par son ID //Efface un menu par son ID
@DeleteMapping(value = "/delete/{id}") @DeleteMapping(value = "/delete/{id}")
@PreAuthorize("hasRole('ROLE_PARENT')") //@PreAuthorize("hasRole('ROLE_PARENT')")
public ResponseEntity<?> deleteMenu(@PathVariable int id){ public ResponseEntity<?> deleteMenu(@PathVariable int id){
try { try {
menuRepository.delete(menuRepository.getById(id)); menuRepository.delete(menuRepository.getById(id));