-
Notifications
You must be signed in to change notification settings - Fork 7
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
상세 조회에서 다른 사람의 비공개 템플릿 확인 시 예외 처리 #852
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.
켬미 작업 너무 빨라~~ RC 남겼으니 확인 바라요~~
public void validateAuthorization(Member member) { | ||
if (!getMember().equals(member)) { | ||
if (!matchMember(member)) { | ||
throw new CodeZapException(ErrorCode.FORBIDDEN_ACCESS, "해당 템플릿에 대한 권한이 없습니다."); | ||
} | ||
} | ||
|
||
public boolean matchMember(Member member) { | ||
return getMember().equals(member); | ||
} | ||
|
||
public void ensureNotPrivateTemplate() { | ||
if (visibility == Visibility.PRIVATE) { | ||
throw new CodeZapException(ErrorCode.FORBIDDEN_ACCESS, "해당 템플릿은 비공개 템플릿입니다."); | ||
} | ||
} |
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.
ErrorCode는 뷰 로직 같은데, 도메인에서 의존하면 안 되지 않을까요?
Template에서는 예외를 직접 발생시키기보다 boolean을 반환하면 더 좋다고 생각하는데, 켬미는 어떤가요?
다음과 같이 제안해요. 메서드명도 바꿔 봤어요!
public boolean ownedBy(Member member) {
return getMember().equals(member);
}
public boolean isPrivate() {
return visibility.isPrivate();
}
public boolean isPublic() {
return visibility.isPublic();
}
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.
켬미 리뷰 하나! 남겼어요~~
수고했어요 🔥
if (!template.matchMember(loginMember) && template.isPrivate()) { | ||
throw new CodeZapException(ErrorCode.FORBIDDEN_ACCESS, "해당 템플릿은 비공개 템플릿입니다."); | ||
} |
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.
메서드 추출해보면 어떨까요~~ 위에 것도!
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.
Commit에 반영 했습니다~
backend/src/main/java/codezap/template/controller/SpringDocTemplateController.java
Show resolved
Hide resolved
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.
고생하셨습니다 켬미~~ 간단한 코멘트라 리체 말고 코멘트로 남겼어요~~
public boolean matchMember(Member member) { | ||
return getMember().equals(member); | ||
} |
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.
일부러 getMember 사용하신건가요?
public boolean matchMember(Member member) { | |
return getMember().equals(member); | |
} | |
public boolean matchMember(Member member) { | |
return this.member.equals(member); | |
} |
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.
Commit에 반영했습니다~
⚡️ 관련 이슈
#739
📍주요 변경 사항
🎸기타
🍗 PR 첫 리뷰 마감 기한
10/23 10:00
해당 PR은 내일 릴리즈 전에 올라가야할 것 같습니다~ 빠른 리뷰 부탁드려요 !