Skip to content

Commit

Permalink
refactor: session key값을 SessionConst로 사용
Browse files Browse the repository at this point in the history
  • Loading branch information
oereo committed Jul 2, 2023
1 parent 0bb36f3 commit 5aed484
Showing 1 changed file with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

import java.util.Optional;

import static com.github.twentiethcenturygangsta.adminboard.SessionConst.LOGIN_MEMBER_CREATE_ADMIN_AUTHORITY;

@Slf4j
@Controller
@RequestMapping("/admin-board")
Expand Down Expand Up @@ -52,10 +54,10 @@ public String Login (Model model, @ModelAttribute("login") LoginRequestDto login
if(adminBoardUser.isPresent()) {
HttpSession session = request.getSession();
session.setAttribute(SessionConst.LOGIN_MEMBER, adminBoardUser.get().getUserId());
session.setAttribute("createAuthority", adminBoardServiceFactory.getAdminBoardUser(adminBoardUser.get().getUserId()).getHasCreateObjectAuthority());
session.setAttribute("createAdminAuthority", adminBoardServiceFactory.getAdminBoardUser(adminBoardUser.get().getUserId()).getHasCreateAdminBoardUserAuthority());
session.setAttribute("updateAuthority", adminBoardServiceFactory.getAdminBoardUser(adminBoardUser.get().getUserId()).getHasUpdateObjectAuthority());
session.setAttribute("deleteAuthority", adminBoardServiceFactory.getAdminBoardUser(adminBoardUser.get().getUserId()).getHasDeleteObjectAuthority());
session.setAttribute(SessionConst.LOGIN_MEMBER_CREATE_AUTHORITY, adminBoardServiceFactory.getAdminBoardUser(adminBoardUser.get().getUserId()).getHasCreateObjectAuthority());
session.setAttribute(LOGIN_MEMBER_CREATE_ADMIN_AUTHORITY, adminBoardServiceFactory.getAdminBoardUser(adminBoardUser.get().getUserId()).getHasCreateAdminBoardUserAuthority());
session.setAttribute(SessionConst.LOGIN_MEMBER_UPDATE_AUTHORITY, adminBoardServiceFactory.getAdminBoardUser(adminBoardUser.get().getUserId()).getHasUpdateObjectAuthority());
session.setAttribute(SessionConst.LOGIN_MEMBER_DELETE_AUTHORITY, adminBoardServiceFactory.getAdminBoardUser(adminBoardUser.get().getUserId()).getHasDeleteObjectAuthority());
return "redirect:/admin-board/task";
} else{
model.addAttribute("error", "일치하는 대시보드 계정이 존재하지 않습니다.");
Expand Down Expand Up @@ -131,7 +133,7 @@ public String createObjectView(Model model, HttpServletRequest request, @PathVar
getSideBarModel(model);
getNavBarModel(model, request);
HttpSession session = request.getSession();
Boolean createAuthority = (Boolean) session.getAttribute("createAuthority");
Boolean createAuthority = (Boolean) session.getAttribute(SessionConst.LOGIN_MEMBER_CREATE_AUTHORITY);
if(!createAuthority) {
return "redirect:/admin-board/" + entityName;
}
Expand All @@ -152,7 +154,7 @@ public String updateObjectView(
getSideBarModel(model);
getNavBarModel(model, request);
HttpSession session = request.getSession();
Boolean updateAuthority = (Boolean) session.getAttribute("updateAuthority");
Boolean updateAuthority = (Boolean) session.getAttribute(SessionConst.LOGIN_MEMBER_UPDATE_AUTHORITY);
if(!updateAuthority) {
return "redirect:/admin-board/" + entityName +"/object/" + id;
}
Expand Down Expand Up @@ -181,13 +183,13 @@ private void getNavBarModel(Model model, HttpServletRequest request) {
String userId = (String) session.getAttribute(SessionConst.LOGIN_MEMBER);
AdminBoardUser adminBoardUser = adminBoardServiceFactory.getAdminBoardUser(userId);
model.addAttribute("userName", userId);
model.addAttribute("createAuthority", adminBoardUser.getHasCreateObjectAuthority());
model.addAttribute("createAdminAuthority", adminBoardUser.getHasCreateAdminBoardUserAuthority());
model.addAttribute("updateAuthority", adminBoardUser.getHasUpdateObjectAuthority());
model.addAttribute("deleteAuthority", adminBoardUser.getHasDeleteObjectAuthority());
session.setAttribute("createAuthority", adminBoardUser.getHasCreateObjectAuthority());
session.setAttribute("createAdminAuthority", adminBoardUser.getHasCreateAdminBoardUserAuthority());
session.setAttribute("updateAuthority", adminBoardUser.getHasUpdateObjectAuthority());
session.setAttribute("deleteAuthority", adminBoardUser.getHasDeleteObjectAuthority());
model.addAttribute(SessionConst.LOGIN_MEMBER_CREATE_AUTHORITY, adminBoardUser.getHasCreateObjectAuthority());
model.addAttribute(LOGIN_MEMBER_CREATE_ADMIN_AUTHORITY, adminBoardUser.getHasCreateAdminBoardUserAuthority());
model.addAttribute(SessionConst.LOGIN_MEMBER_UPDATE_AUTHORITY, adminBoardUser.getHasUpdateObjectAuthority());
model.addAttribute(SessionConst.LOGIN_MEMBER_DELETE_AUTHORITY, adminBoardUser.getHasDeleteObjectAuthority());
session.setAttribute(SessionConst.LOGIN_MEMBER_CREATE_AUTHORITY, adminBoardUser.getHasCreateObjectAuthority());
session.setAttribute(LOGIN_MEMBER_CREATE_ADMIN_AUTHORITY, adminBoardUser.getHasCreateAdminBoardUserAuthority());
session.setAttribute(SessionConst.LOGIN_MEMBER_UPDATE_AUTHORITY, adminBoardUser.getHasUpdateObjectAuthority());
session.setAttribute(SessionConst.LOGIN_MEMBER_DELETE_AUTHORITY, adminBoardUser.getHasDeleteObjectAuthority());
}
}

0 comments on commit 5aed484

Please sign in to comment.