Skip to content

Commit

Permalink
[#168] fix(authority)
Browse files Browse the repository at this point in the history
- 권한 검사할 때, folder를 통해 검사하도록 변경함.
- remindOn할 때, remind가 존재하면 추가되지 않도록 변경함.
  • Loading branch information
Ji-Ha committed Aug 12, 2022
1 parent bcc7272 commit a35ca33
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,14 @@ class SharedBookmarkService(
private val jwtProvider: JwtProvider
) {

@Transactional(readOnly = true)
fun checkAuthority(account: Account, folderId: Long) {
var folder = folderRepository.findFolderById(folderId) ?: throw FolderNotFoundException()

if (folder.rootFolderId != null) folder =
folderRepository.findFolderById(folder.rootFolderId!!) ?: throw FolderNotFoundException()

// 존재하면? 일단 공유 멤버이니까 return
for (af in account.accountFolderList)
if (af.folder == folder && af.authority > Authority.NONE) return
for (af in folder.folders!!)
if (af.account == account && af.authority > Authority.NONE) return

throw NoPermissionException()
}
Expand Down Expand Up @@ -132,6 +130,8 @@ class SharedBookmarkService(
val folderId = bookmark.folderId ?: throw RuntimeException("폴더에 속해있지 않습니다!")
val remind = Remind(account)

if(bookmark.isRemindExist(remind)) return

checkAuthority(account, folderId)

bookmark.remindOn(remind)
Expand Down

0 comments on commit a35ca33

Please sign in to comment.