diff --git a/backend/src/main/java/com/edufocus/edufocus/video/controller/Controller.java b/backend/src/main/java/com/edufocus/edufocus/video/controller/Controller.java index 6dbba66..0996fa4 100644 --- a/backend/src/main/java/com/edufocus/edufocus/video/controller/Controller.java +++ b/backend/src/main/java/com/edufocus/edufocus/video/controller/Controller.java @@ -95,18 +95,21 @@ public class Controller { } else if (findUser.getRole() == UserRole.ADMIN) {//&& lecture.isOnline() ) { - - IdentityData identityData = new IdentityData(participantName, "강사"); - String jsonIdentity = serializeIdentityData(identityData); + // 자신의 강의인지 확인하기 + if (videoSertvice.checkAdmin(userId, id)) { + IdentityData identityData = new IdentityData(participantName, "강사"); + String jsonIdentity = serializeIdentityData(identityData); - token.setIdentity(jsonIdentity); - token.setName(participantName); + token.setIdentity(jsonIdentity); + token.setName(participantName); - token.addGrants(new RoomJoin(true), new RoomName(roomName), new RoomCreate(true)); + token.addGrants(new RoomJoin(true), new RoomName(roomName), new RoomCreate(true)); - return ResponseEntity.ok(Map.of("token", token.toJwt())); + return ResponseEntity.ok(Map.of("token", token.toJwt())); + } + } diff --git a/backend/src/main/java/com/edufocus/edufocus/video/service/VideoSertvice.java b/backend/src/main/java/com/edufocus/edufocus/video/service/VideoSertvice.java index 71b34d9..f45cdc4 100644 --- a/backend/src/main/java/com/edufocus/edufocus/video/service/VideoSertvice.java +++ b/backend/src/main/java/com/edufocus/edufocus/video/service/VideoSertvice.java @@ -10,4 +10,6 @@ public interface VideoSertvice { boolean isRoomAccessible(Long lectureId, Long userId); + boolean checkAdmin(Long userId, Long lectureId); + } diff --git a/backend/src/main/java/com/edufocus/edufocus/video/service/VideoServiceImpl.java b/backend/src/main/java/com/edufocus/edufocus/video/service/VideoServiceImpl.java index cf9714e..055e133 100644 --- a/backend/src/main/java/com/edufocus/edufocus/video/service/VideoServiceImpl.java +++ b/backend/src/main/java/com/edufocus/edufocus/video/service/VideoServiceImpl.java @@ -2,6 +2,7 @@ package com.edufocus.edufocus.video.service; import com.edufocus.edufocus.lecture.entity.Lecture; import com.edufocus.edufocus.lecture.entity.LectureDetailResponse; +import com.edufocus.edufocus.lecture.entity.LectureSearchResponse; import com.edufocus.edufocus.lecture.service.LectureService; import com.edufocus.edufocus.registration.entity.RegistrationStatus; import com.edufocus.edufocus.registration.service.RegistrationService; @@ -10,6 +11,7 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import java.sql.SQLException; +import java.util.List; @Service @Transactional @@ -46,4 +48,17 @@ public class VideoServiceImpl implements VideoSertvice { return false; } } + + @Override + public boolean checkAdmin(Long userId, Long lectureId) { + // 강의가 내 강의인지 확인 + List lecture = lectureService.findMyLecture(userId); + + for (LectureSearchResponse l : lecture) { + if (l.getId() == lectureId) { + return true; + } + } + return false; + } }