Skip to content

Commit

Permalink
feat: 어드민, 멘토, 즉 게스트인 회원에 대한 접근을 검증하는 로직 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
AlmondBreez3 committed Aug 14, 2024
1 parent 90846e6 commit 55f4ce6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ public List<StudyStudentResponse> getStudyStudents(Long studyId) {
Study study =
studyRepository.findById(studyId).orElseThrow(() -> new CustomException(ErrorCode.STUDY_NOT_FOUND));

studyValidator.validateStudyMentor(
currentMember.getId(), study.getMentor().getId());
studyValidator.validateStudyMentor(currentMember, study.getMentor().getId());
List<StudyHistory> studyHistories = studyHistoryRepository.findByStudyId(studyId);

return studyHistories.stream().map(StudyStudentResponse::from).toList();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
package com.gdschongik.gdsc.domain.study.domain;

import static com.gdschongik.gdsc.global.exception.ErrorCode.STUDY_MENTOR_INVALID;
import static com.gdschongik.gdsc.global.exception.ErrorCode.STUDY_MENTOR_IS_UNAUTHORIZED;

import com.gdschongik.gdsc.domain.member.domain.Member;
import com.gdschongik.gdsc.global.annotation.DomainService;
import com.gdschongik.gdsc.global.exception.CustomException;

@DomainService
public class StudyValidator {
public void validateStudyMentor(Long currentMemberId, Long mentorId) {
if (!currentMemberId.equals(mentorId)) {
public void validateStudyMentor(Member currentMember, Long mentorId) {
if (currentMember.isGuest()) {
throw new CustomException(STUDY_MENTOR_IS_UNAUTHORIZED);
}

if (!currentMember.getId().equals(mentorId)) {
throw new CustomException(STUDY_MENTOR_INVALID);
}
}
Expand Down

0 comments on commit 55f4ce6

Please sign in to comment.