-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
7주차 미션 / 서버 3조 이윤희 #14
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
코드 리뷰를 작성하고 공개를 안했네요 😢 미션 수행하느라 고생하셨어요!!
@RequestParam String name, | ||
@RequestParam String email | ||
){ | ||
User user = new User(userId, password, name, email); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
userId가 일치하는 회원이 존재하는지 확인하는 절차가 추가하면 좋을 것 같아요. 실제 서비스에서는 동일한 id를 갖는 회원이 존재하면 안되니까요.
if (UserSessionUtils.isLoggedIn(session)) { | ||
User sessionUser = (User) session.getAttribute(USER_SESSION_KEY); | ||
if (sessionUser != null && sessionUser.getUserId().equals(userId)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
83번 줄에서 UserSessionUtils의 isLoggedIn()으로 로그인되어 있는지 여부를 확인했기 때문에 여기서 인가가 끝납니다. 그래서 이후에 조건식 2줄은 중복되는 내용이라 없어도 될 것 같네요!
if (user != null) { | ||
model.addAttribute("user", user); | ||
return "user/updateForm"; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
정말 예외적인 상황이지만 repository로 조회해보니 user가 삭제되어서 없을 수도 있을 것 같네요. 만약 user가 존재하지 않아서 null이라면, 이 코드상으로는 /user/list로 redirect하는데 실제 서비스에서는 어떻게 동작하는 게 좋을지 고민해보는 것도 좋을 것 같아요
User modifiedUser = new User(userId, password, name, email); | ||
userRepository.update(modifiedUser); | ||
log.info("updateUserV1 done"); | ||
return "redirect:/user/list"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
수정 시에도 인가가 필요하지 않을까요?
No description provided.