fix(api): prevent retrieving own user activity in demo profile

closes #643
This commit is contained in:
Gauthier Roebroeck 2021-09-01 11:56:15 +08:00
parent 619e51bdcd
commit 59c187f3b7

View file

@ -161,6 +161,7 @@ class UserController(
@RequestParam(name = "unpaged", required = false) unpaged: Boolean = false,
@Parameter(hidden = true) page: Pageable,
): Page<AuthenticationActivityDto> {
if (demo && !principal.user.roleAdmin) throw ResponseStatusException(HttpStatus.FORBIDDEN)
val sort =
if (page.sort.isSorted) page.sort
else Sort.by(Sort.Order.desc("dateTime"))