Skip to content

Commit

Permalink
fix(api): libraries are not sorted for restricted users
Browse files Browse the repository at this point in the history
Closes: #140
  • Loading branch information
gotson committed Apr 13, 2020
1 parent c9de7c8 commit 1d58322
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import org.gotson.komga.domain.model.PathContainedInPath
import org.gotson.komga.domain.persistence.BookRepository
import org.gotson.komga.domain.persistence.LibraryRepository
import org.gotson.komga.infrastructure.security.KomgaPrincipal
import org.springframework.data.domain.Sort
import org.springframework.data.repository.findByIdOrNull
import org.springframework.http.HttpStatus
import org.springframework.http.MediaType
Expand Down Expand Up @@ -46,10 +45,10 @@ class LibraryController(
@AuthenticationPrincipal principal: KomgaPrincipal
): List<LibraryDto> =
if (principal.user.sharedAllLibraries) {
libraryRepository.findAll(Sort.by("name"))
libraryRepository.findAll()
} else {
principal.user.sharedLibraries
}.map { it.toDto(includeRoot = principal.user.isAdmin()) }
}.sortedBy { it.name }.map { it.toDto(includeRoot = principal.user.isAdmin()) }

@GetMapping("{id}")
fun getOne(
Expand Down

0 comments on commit 1d58322

Please sign in to comment.