Skip to content
Snippets Groups Projects
Commit b7e97077 authored by Antoine Hazebrouck's avatar Antoine Hazebrouck
Browse files

fix acces aux notes des autres

parent 7f665c11
No related branches found
No related tags found
No related merge requests found
......@@ -52,21 +52,36 @@ public class MainController {
createNewNote(user);
}
user.getNotes().sort(new Comparator<Note>() {
// si la note $note_id n'appartient pas a l'utilisateur
Boolean note_idNotInUserNotes = false;
for (Note note : user.getNotes()) {
if (note.getId() == note_id) {
note_idNotInUserNotes = true;
}
}
if (note_idNotInUserNotes == false) {
return "redirect:/";
}
// if (user.getNotes().stream().anyMatch(new Predicate<Note>() {
// @Override
// public boolean test(Note note) {
// return note.getId() == note_id;
// }
// })) {
// return "redirect:/";
// }
user.getNotes().sort(new Comparator<Note>() {
@Override
public int compare(Note o1, Note o2) {
return o1.getId() - o2.getId();
}
});
model.addAttribute("note_id", note_id);
model.addAttribute("notes", notesService.findById(note_id));
// model.addAttribute("notes", user.getNotes().get(note_id - 1));
// List<String> titles = new ArrayList<>();
// for (Note note : user.getNotes()) {
// titles.add(note.getTitle());
// }
model.addAttribute("allNotes", user.getNotes());
return "main_page.html";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment