From 1278bc82510644526869ed0ec87c4cac1a820c9a Mon Sep 17 00:00:00 2001 From: ZheChrisMajor <65349713+ZheChrisMajor@users.noreply.github.com> Date: Tue, 21 Mar 2023 14:08:04 +0100 Subject: [PATCH] fix: Redirect to public on invalid endpoint --- .../dk/itu/minitwit/controller/MiniTwitController.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/MiniTwit/src/main/java/dk/itu/minitwit/controller/MiniTwitController.java b/MiniTwit/src/main/java/dk/itu/minitwit/controller/MiniTwitController.java index 0ba17ac..14e63d0 100644 --- a/MiniTwit/src/main/java/dk/itu/minitwit/controller/MiniTwitController.java +++ b/MiniTwit/src/main/java/dk/itu/minitwit/controller/MiniTwitController.java @@ -105,7 +105,14 @@ public String userTimeLine(@PathVariable("username") String username, HttpServle model.addAttribute("public", "false"); model.addAttribute("username", username); Boolean loggedIn = addUserToModel(model, session); - + + List arg = new ArrayList<>(); // + arg.add(username); // + List> users; // check if there is a user with this name + users = sqLite.queryDb("select * from user where user.username = ?", arg); // redirect to public if there is no such user + if (users.size()==0) return "redirect:/public"; // todo redirect to error page insted + + if (loggedIn) { //TODO bliver kaldt af favicon ?? // System.out.println("username: " + username);