Skip to content
Snippets Groups Projects

Resolve "Feedback should be clearly anonymous"

4 files
+ 34
6
Compare changes
  • Side-by-side
  • Inline

Files

@@ -221,7 +221,7 @@ public class HomeController {
@PreAuthorize("@permissionService.canViewOwnFeedback()")
public String ownFeedback(@AuthenticatedPerson Person person,
Model model, Pageable pageable) {
fillInFeedbackModel(person.getId(), model, pageable);
fillInFeedbackModel(person.getId(), person, model, pageable);
return "home/feedback";
}
@@ -229,6 +229,7 @@ public class HomeController {
/**
* Maps the feedback url to a page. The Feedback page displays feedback for a user with the given ID.
*
* @param person The person that is currently authenticated.
* @param id The id of the person for which feedback will be shown.
* @param model The model to be filled out for Thymeleaf resolution.
* @param pageable The Pageable object representing the current page state.
@@ -236,9 +237,9 @@ public class HomeController {
*/
@GetMapping("/feedback/{id}")
@PreAuthorize("@permissionService.canViewFeedback(#id)")
public String feedback(@PathVariable("id") Long id,
public String feedback(@AuthenticatedPerson Person person, @PathVariable("id") Long id,
Model model, Pageable pageable) {
fillInFeedbackModel(id, model, pageable);
fillInFeedbackModel(id, person, model, pageable);
return "home/feedback";
}
@@ -247,13 +248,16 @@ public class HomeController {
* Fills in the model for a page where feedback is shown to the user.
*
* @param assistantId The id of the user to find assistant for (this could be the current user).
* @param person The person that is currently authenticated.
* @param model The model that is to be filled.
* @param pageable The pageable containing information on how much feedback needs to be shown.
*/
private void fillInFeedbackModel(Long assistantId, Model model, Pageable pageable) {
private void fillInFeedbackModel(Long assistantId, Person person, Model model, Pageable pageable) {
var assistant = pCache.getOrThrow(assistantId);
Page<Feedback> feedback = fr.findByAssistant(assistantId, pageable);
Page<Feedback> feedback = assistantId.equals(person.getId())
? fr.findByAssistantAnonymised(assistantId, pageable)
: fr.findByAssistant(assistantId, pageable);
model.addAttribute("assistant", assistant);
model.addAttribute("feedback",
Loading