CORRECTION BUG & AMELIORATION : Gestion de la visibilite et des partages de photos (ACL)
This commit is contained in:
@@ -18,6 +18,9 @@ import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
@Controller
|
||||
public class PhotoController {
|
||||
|
||||
@@ -181,8 +184,13 @@ public class PhotoController {
|
||||
@RequestParam String permission,
|
||||
Authentication auth) {
|
||||
|
||||
partageService.share(id, email, permission, auth.getName());
|
||||
return "redirect:/photo/" + id + "?shared=ok";
|
||||
try {
|
||||
partageService.share(id, email, permission, auth.getName());
|
||||
return "redirect:/photo/" + id + "?shared=ok";
|
||||
} catch (RuntimeException ex) {
|
||||
return "redirect:/photo/" + id + "?error=" + URLEncoder.encode(ex.getMessage(), StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -193,4 +201,18 @@ public class PhotoController {
|
||||
partageService.unshare(id, email);
|
||||
return "redirect:/photo/" + id;
|
||||
}
|
||||
|
||||
/* ========================== MAJ MODE PARTAGE ========================== */
|
||||
@PostMapping("/photo/{id}/share/update")
|
||||
@PreAuthorize("@securityService.canAccessPhoto(authentication, #id)")
|
||||
public String updateShare(
|
||||
@PathVariable Long id,
|
||||
@RequestParam String email,
|
||||
@RequestParam String permission,
|
||||
Authentication auth
|
||||
) {
|
||||
partageService.updatePermission(id, email, permission, auth.getName());
|
||||
return "redirect:/photo/" + id;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user