From afc46e3c414122d283b4af45ec0cf52a718b5bf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C5=82awek=20Zatorski?= Date: Sat, 30 Nov 2024 11:02:45 +0100 Subject: [PATCH] ROLE_COUNTER --- .../sasiedzi/event/security/AuthoritiesConstants.java | 2 ++ .../java/com/sasiedzi/event/web/rest/EventResource.java | 8 ++++---- .../com/sasiedzi/event/web/rest/TransactionResource.java | 6 +++--- src/main/webapp/app/entities/event/event-details.vue | 5 +++-- .../app/entities/transaction/transaction-details.vue | 4 ++-- src/main/webapp/app/entities/transaction/transaction.vue | 9 +++++++-- 6 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/sasiedzi/event/security/AuthoritiesConstants.java b/src/main/java/com/sasiedzi/event/security/AuthoritiesConstants.java index 65cca42..3b4e62c 100644 --- a/src/main/java/com/sasiedzi/event/security/AuthoritiesConstants.java +++ b/src/main/java/com/sasiedzi/event/security/AuthoritiesConstants.java @@ -9,6 +9,8 @@ public final class AuthoritiesConstants { public static final String USER = "ROLE_USER"; + public static final String COUNTER = "ROLE_COUNTER"; + public static final String ANONYMOUS = "ROLE_ANONYMOUS"; private AuthoritiesConstants() {} diff --git a/src/main/java/com/sasiedzi/event/web/rest/EventResource.java b/src/main/java/com/sasiedzi/event/web/rest/EventResource.java index 62553ec..eacf468 100644 --- a/src/main/java/com/sasiedzi/event/web/rest/EventResource.java +++ b/src/main/java/com/sasiedzi/event/web/rest/EventResource.java @@ -52,7 +52,7 @@ public class EventResource { * @throws URISyntaxException if the Location URI syntax is incorrect. */ @PostMapping("") - @Secured({ AuthoritiesConstants.ADMIN }) + @Secured({ AuthoritiesConstants.ADMIN, AuthoritiesConstants.COUNTER }) public ResponseEntity createEvent(@Valid @RequestBody Event event) throws URISyntaxException { LOG.debug("REST request to save Event : {}", event); if (event.getId() != null) { @@ -65,7 +65,7 @@ public class EventResource { } @PostMapping("/{id}/settle") - @Secured({ AuthoritiesConstants.ADMIN }) + @Secured({ AuthoritiesConstants.ADMIN, AuthoritiesConstants.COUNTER }) public ResponseEntity> settleEvent(@RequestBody Optional event) throws URISyntaxException { event = eventService.settle(event.orElse(null)); return ResponseEntity.ok() @@ -84,7 +84,7 @@ public class EventResource { * @throws URISyntaxException if the Location URI syntax is incorrect. */ @PutMapping("/{id}") - @Secured({ AuthoritiesConstants.ADMIN }) + @Secured({ AuthoritiesConstants.ADMIN, AuthoritiesConstants.COUNTER }) public ResponseEntity updateEvent(@PathVariable(value = "id", required = false) final Long id, @Valid @RequestBody Event event) throws URISyntaxException { LOG.debug("REST request to update Event : {}, {}", id, event); @@ -116,7 +116,7 @@ public class EventResource { * or with status {@code 500 (Internal Server Error)} if the event couldn't be updated. * @throws URISyntaxException if the Location URI syntax is incorrect. */ - @Secured({ AuthoritiesConstants.ADMIN }) + @Secured({ AuthoritiesConstants.ADMIN, AuthoritiesConstants.COUNTER }) @PatchMapping(value = "/{id}", consumes = { "application/json", "application/merge-patch+json" }) public ResponseEntity partialUpdateEvent( @PathVariable(value = "id", required = false) final Long id, diff --git a/src/main/java/com/sasiedzi/event/web/rest/TransactionResource.java b/src/main/java/com/sasiedzi/event/web/rest/TransactionResource.java index d117a2d..ad16b44 100644 --- a/src/main/java/com/sasiedzi/event/web/rest/TransactionResource.java +++ b/src/main/java/com/sasiedzi/event/web/rest/TransactionResource.java @@ -50,7 +50,7 @@ public class TransactionResource { * @throws URISyntaxException if the Location URI syntax is incorrect. */ @PostMapping("") - @Secured({ AuthoritiesConstants.ADMIN }) + @Secured({ AuthoritiesConstants.ADMIN, AuthoritiesConstants.COUNTER }) public ResponseEntity createTransaction(@RequestBody Transaction transaction) throws URISyntaxException { LOG.debug("REST request to save Transaction : {}", transaction); if (transaction.getId() != null) { @@ -72,7 +72,7 @@ public class TransactionResource { * or with status {@code 500 (Internal Server Error)} if the transaction couldn't be updated. * @throws URISyntaxException if the Location URI syntax is incorrect. */ - @Secured({ AuthoritiesConstants.ADMIN }) + @Secured({ AuthoritiesConstants.ADMIN, AuthoritiesConstants.COUNTER }) @PutMapping("/{id}") public ResponseEntity updateTransaction( @PathVariable(value = "id", required = false) final Long id, @@ -107,7 +107,7 @@ public class TransactionResource { * or with status {@code 500 (Internal Server Error)} if the transaction couldn't be updated. * @throws URISyntaxException if the Location URI syntax is incorrect. */ - @Secured({ AuthoritiesConstants.ADMIN }) + @Secured({ AuthoritiesConstants.ADMIN, AuthoritiesConstants.COUNTER }) @PatchMapping(value = "/{id}", consumes = { "application/json", "application/merge-patch+json" }) public ResponseEntity partialUpdateTransaction( @PathVariable(value = "id", required = false) final Long id, diff --git a/src/main/webapp/app/entities/event/event-details.vue b/src/main/webapp/app/entities/event/event-details.vue index b509d28..9f475a0 100644 --- a/src/main/webapp/app/entities/event/event-details.vue +++ b/src/main/webapp/app/entities/event/event-details.vue @@ -45,7 +45,7 @@  Dołącz do wydarzenia -
@@ -77,7 +77,8 @@ class="btn btn-sm" data-cy="entityDeleteButton" v-if=" - ((registration.id && registration.user?.id == currentUserId && isCurrentEvent) || hasAnyAuthority('ROLE_ADMIN')) && + ((registration.id && registration.user?.id == currentUserId && isCurrentEvent) || + hasAnyAuthority(['ROLE_ADMIN', 'ROLE_COUNTER'])) && registration.active !== false " v-b-modal.removeEntity diff --git a/src/main/webapp/app/entities/transaction/transaction-details.vue b/src/main/webapp/app/entities/transaction/transaction-details.vue index 6427992..da82789 100644 --- a/src/main/webapp/app/entities/transaction/transaction-details.vue +++ b/src/main/webapp/app/entities/transaction/transaction-details.vue @@ -40,7 +40,7 @@ custom v-slot="{ navigate }" > - @@ -50,7 +50,7 @@ custom v-slot="{ navigate }" > - diff --git a/src/main/webapp/app/entities/transaction/transaction.vue b/src/main/webapp/app/entities/transaction/transaction.vue index 5c6e9a5..7afab87 100644 --- a/src/main/webapp/app/entities/transaction/transaction.vue +++ b/src/main/webapp/app/entities/transaction/transaction.vue @@ -6,7 +6,12 @@ - +