Secures get all hunts by admin role

This commit is contained in:
2026-04-09 16:24:14 -05:00
parent 9633d95e75
commit 69e874c9f2
2 changed files with 4 additions and 1 deletions

View File

@@ -10,6 +10,7 @@ import net.halfbinary.scavengerhuntapi.model.request.HuntStatus
import net.halfbinary.scavengerhuntapi.model.response.HuntResponse
import net.halfbinary.scavengerhuntapi.service.HuntService
import org.springframework.http.ResponseEntity
import org.springframework.security.access.prepost.PreAuthorize
import org.springframework.web.bind.annotation.*
@RestController
@@ -21,6 +22,7 @@ class HuntController(private val huntService: HuntService) {
return ResponseEntity.ok(huntService.getHunt(huntId).toResponse())
}
@PreAuthorize("hasRole('ADMIN')")
@GetMapping()
fun getAllHunts(@RequestParam status: HuntStatus?): ResponseEntity<List<HuntResponse>> {
return ResponseEntity.ok(huntService.getAllHunts(status).map { it.toResponse() })