@RequestMapping(value = "/mypage/grantadmin.do", method = RequestMethod.POST) public String grantAdmin(@RequestParam("userList") List<String> userList) { for (String userId : userList) { UserView user = new UserView(); user.setUserId(userId); user.setAuthName(Auth.ROLE_ADMIN); userService.grantAuth(user); } return "redirect:" + "/mypage/grantadmin.do"; }
@RequestMapping(value = "/mypage/withdraw.do", method = RequestMethod.POST) public String withdraw(@RequestParam("userPW") String userPW) { Authentication auth = SecurityContextHolder.getContext().getAuthentication(); String userId = auth.getName(); // get logged in userId String url = ""; boolean isUser = userService.removeUser(userId, userPW); if (isUser) url = "redirect:" + "/logout.do"; else url = "redirect:" + "/main/main.do?message=fail"; return url; }
@RequestMapping(value = "/mypage/changepw.do", method = RequestMethod.POST) public String changePW( @RequestParam("preUserPW") String preUserPW, @RequestParam("userPW") String userPW) { Authentication auth = SecurityContextHolder.getContext().getAuthentication(); String userId = auth.getName(); String url = ""; boolean isUser = false; isUser = userService.changePW(userId, preUserPW, userPW); if (isUser) url = "redirect:" + "/main/main.do?message=changepw"; else url = "redirect:" + "/main/main.do?message=fail"; return url; }
@RequestMapping(value = "/mypage/modify.do", method = RequestMethod.POST) public String modify(@ModelAttribute("userView") UserView userView) throws Exception { Authentication auth = SecurityContextHolder.getContext().getAuthentication(); String url = ""; boolean isUser = false; userView.setUserId(auth.getName()); isUser = userService.modifyUser(userView); if (isUser) url = "redirect:" + "/main/main.do?message=modify"; else url = "redirect:" + "/main/main.do?message=fail"; return url; }
@RequestMapping(value = "/mypage/grantadmin.do", method = RequestMethod.GET) public ModelAndView viewGrantAdmin() { ModelAndView modelAndView = new ModelAndView("/mypage/grantadmin"); Pagination pagination = new Pagination(); pagination.setSrchType("authName"); pagination.setContent(Auth.ROLE_ADMIN); List<UserView> userList = userService.findUsers(pagination); modelAndView.addObject("userList", userList); modelAndView.addObject("subTitle", "관리자권한 부여"); modelAndView.addObject("mypageType", "grantadmin"); return modelAndView; }
@RequestMapping(value = "/mypage/modify.do", method = RequestMethod.POST, params = "cmd=modify") public ModelAndView viewModify(@RequestParam("userPW") String userPW) throws Exception { ModelAndView modelAndView = new ModelAndView("/mypage/modify"); Authentication auth = SecurityContextHolder.getContext().getAuthentication(); UserView userView = userService.getUser(auth.getName(), userPW); // 비밀번호 틀렸을 경우 if (userView == null) { modelAndView.setViewName("redirect:/mypage/modify.do?cmd=chkpw"); return modelAndView; } modelAndView.addObject("userView", userView); modelAndView.addObject("subTitle", "회원수정"); modelAndView.addObject("mypageType", "modify"); return modelAndView; }
@RequestMapping(value = "/mypage/returnauth.do") public String grantAdmin(@RequestParam("ui") String userId) { userService.returnAuth(userId); return "redirect:" + "/mypage/grantadmin.do"; }