File tree Expand file tree Collapse file tree 3 files changed +15
-1
lines changed
src/main/kotlin/com/wafflestudio/csereal Expand file tree Collapse file tree 3 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,11 @@ fun isCurrentUserStaff(): Boolean {
5050 return " ROLE_STAFF" in getCurrentUserRoles()
5151}
5252
53+ fun isCurrentUserStaffOrProfessor (): Boolean {
54+ val roles = getCurrentUserRoles()
55+ return " ROLE_STAFF" in roles || " ROLE_PROFESSOR" in roles
56+ }
57+
5358fun getCurrentUserRoles (): List <String > {
5459 val authentication = SecurityContextHolder .getContext().authentication ? : /* for test */ return listOf (" ROLE_STAFF" )
5560 return authentication.authorities.map { it.authority }
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package com.wafflestudio.csereal.core.reservation.service
22
33import com.wafflestudio.csereal.common.CserealException
44import com.wafflestudio.csereal.common.utils.isCurrentUserStaff
5+ import com.wafflestudio.csereal.common.utils.isCurrentUserStaffOrProfessor
56import com.wafflestudio.csereal.core.reservation.database.*
67import com.wafflestudio.csereal.core.reservation.dto.ReservationDto
78import com.wafflestudio.csereal.core.reservation.dto.ReserveRequest
@@ -40,7 +41,12 @@ class ReservationServiceImpl(
4041 roomRepository.findRoomById(reserveRequest.roomId) ? : throw CserealException .Csereal404 (" Room Not Found" )
4142
4243 // 현재 일반 예약 권한으로 교수회의실 제외한 세미나실만 예약 가능 (행정실 요청)
43- if (! isCurrentUserStaff() && (reserveRequest.roomId == 8L || room.type != RoomType .SEMINAR )) {
44+ if (! isCurrentUserStaff() && room.type != RoomType .SEMINAR ) {
45+ throw CserealException .Csereal403 (" 예약 불가. 행정실 문의 바람" )
46+ }
47+
48+ // 세미나실 중 교수회의실은 스태프 또는 교수만 예약 가능
49+ if (! isCurrentUserStaffOrProfessor() && reserveRequest.roomId == 8L ) {
4450 throw CserealException .Csereal403 (" 예약 불가. 행정실 문의 바람" )
4551 }
4652
Original file line number Diff line number Diff line change @@ -51,6 +51,9 @@ class CustomOidcUserService(
5151 if (" professor" in groups || " graduate" in groups) {
5252 authorities.add(SimpleGrantedAuthority (" ROLE_RESERVATION" ))
5353 }
54+ if (" professor" in groups) {
55+ authorities.add(SimpleGrantedAuthority (" ROLE_PROFESSOR" ))
56+ }
5457 if (" student-council" in groups) {
5558 authorities.add(SimpleGrantedAuthority (" ROLE_COUNCIL" ))
5659 }
You can’t perform that action at this time.
0 commit comments