Skip to content

Commit

Permalink
[BE] hotfix: id, key Session 에 따로 저장 (#751)
Browse files Browse the repository at this point in the history
  • Loading branch information
wugawuga authored Oct 12, 2023
1 parent 1c3fa0e commit dc20956
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ public AdminLoginController(final AdminChecker adminChecker) {
}

@PostMapping("/login")
public ResponseEntity<Void> login(@RequestBody final AdminAuthInfo adminAuthInfo, final HttpServletRequest request) {
public ResponseEntity<Void> login(@RequestBody final AdminAuthInfo adminAuthInfo,
final HttpServletRequest request) {
adminChecker.check(adminAuthInfo);

request.getSession().setAttribute("authInfo", adminAuthInfo);
request.getSession().setAttribute("authId", adminAuthInfo.getId());
request.getSession().setAttribute("authKey", adminAuthInfo.getKey());

return ResponseEntity.noContent().build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ public boolean preHandle(final HttpServletRequest request, final HttpServletResp
throw new NotLoggedInException(LOGIN_ADMIN_NOT_FOUND);
}

final AdminAuthInfo adminAuthInfo = (AdminAuthInfo) session.getAttribute("authInfo");
final String authId = String.valueOf(session.getAttribute("authId"));
final String authKey = String.valueOf(session.getAttribute("authKey"));

if (Objects.isNull(adminAuthInfo)) {
if (Objects.isNull(authId) || Objects.isNull(authKey)) {
throw new NotLoggedInException(LOGIN_ADMIN_NOT_FOUND);
}

return adminChecker.check(adminAuthInfo);
return adminChecker.check(new AdminAuthInfo(authId, authKey));
}
}

0 comments on commit dc20956

Please sign in to comment.