From 7b8a99a6074228a5680218690b7f1538ce7e8d1d Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 8 Dec 2022 07:26:58 +0300 Subject: Cleanup unused authorization checks handled by spring-security --- src/main/java/com/juick/www/controllers/Settings.java | 13 ++++--------- src/main/java/com/juick/www/controllers/Site.java | 6 ------ 2 files changed, 4 insertions(+), 15 deletions(-) (limited to 'src/main/java/com/juick/www/controllers') diff --git a/src/main/java/com/juick/www/controllers/Settings.java b/src/main/java/com/juick/www/controllers/Settings.java index 1e40b9d1..0b486766 100644 --- a/src/main/java/com/juick/www/controllers/Settings.java +++ b/src/main/java/com/juick/www/controllers/Settings.java @@ -91,18 +91,13 @@ public class Settings { protected String doGet( @Visitor User visitor, Locale locale, - HttpServletRequest request, - HttpServletResponse response, ModelMap model) throws IOException { - if (visitor.isAnonymous()) { - response.sendRedirect("/login"); - } + @RequestParam(required = false, defaultValue = "main") String page, + @RequestParam(required = false) String code, ModelMap model) throws IOException { visitor.setAvatar(webApp.getAvatarWebPath(visitor)); List pages = Arrays.asList("main", "password", "about", "auth-email", "privacy"); - String page = request.getParameter("page"); - if (StringUtils.isEmpty(page) || !pages.contains(page)) { + if (!pages.contains(page)) { page = "main"; } - model.addAttribute("title", ResourceBundle.getBundle("messages", locale).getString("link.settings")); model.addAttribute("visitor", visitor); model.addAttribute("tags", tagService.getPopularTags()); @@ -120,7 +115,7 @@ public class Settings { model.addAttribute("notify_options", subscriptionService.getNotifyOptions(visitor)); model.addAttribute("userinfo", userService.getUserInfo(visitor)); if (page.equals("auth-email")) { - if (emailService.verifyAddressByCode(visitor.getUid(), request.getParameter("code"))) { + if (emailService.verifyAddressByCode(visitor.getUid(), code)) { model.addAttribute("result", "OK!"); } else { model.addAttribute("result", "Sorry, code unknown."); diff --git a/src/main/java/com/juick/www/controllers/Site.java b/src/main/java/com/juick/www/controllers/Site.java index aa6d574d..e28f8e15 100644 --- a/src/main/java/com/juick/www/controllers/Site.java +++ b/src/main/java/com/juick/www/controllers/Site.java @@ -451,9 +451,6 @@ public class Site { @GetMapping("/pm/inbox") protected String doGetInbox(@Visitor User visitor, ModelMap model) { - if (visitor.isAnonymous()) { - return "redirect:/login"; - } visitor.setAvatar(webApp.getAvatarWebPath(visitor)); String title = "PM: Inbox"; List msgs = pmQueriesService.getLastPMInbox(visitor.getUid()); @@ -468,9 +465,6 @@ public class Site { @GetMapping("/pm/sent") protected String doGetSent(@Visitor User visitor, @RequestParam(required = false) String uname, ModelMap model) { - if (visitor.isAnonymous()) { - return "redirect:/login"; - } visitor.setAvatar(webApp.getAvatarWebPath(visitor)); String title = "PM: Sent"; List msgs = pmQueriesService.getLastPMSent(visitor.getUid()); -- cgit v1.2.3