ROLE_COUNTER

This commit is contained in:
2024-11-30 11:02:45 +01:00
parent 5d6a0ae3e1
commit afc46e3c41
6 changed files with 21 additions and 13 deletions
@@ -9,6 +9,8 @@ public final class AuthoritiesConstants {
public static final String USER = "ROLE_USER"; public static final String USER = "ROLE_USER";
public static final String COUNTER = "ROLE_COUNTER";
public static final String ANONYMOUS = "ROLE_ANONYMOUS"; public static final String ANONYMOUS = "ROLE_ANONYMOUS";
private AuthoritiesConstants() {} private AuthoritiesConstants() {}
@@ -52,7 +52,7 @@ public class EventResource {
* @throws URISyntaxException if the Location URI syntax is incorrect. * @throws URISyntaxException if the Location URI syntax is incorrect.
*/ */
@PostMapping("") @PostMapping("")
@Secured({ AuthoritiesConstants.ADMIN }) @Secured({ AuthoritiesConstants.ADMIN, AuthoritiesConstants.COUNTER })
public ResponseEntity<Event> createEvent(@Valid @RequestBody Event event) throws URISyntaxException { public ResponseEntity<Event> createEvent(@Valid @RequestBody Event event) throws URISyntaxException {
LOG.debug("REST request to save Event : {}", event); LOG.debug("REST request to save Event : {}", event);
if (event.getId() != null) { if (event.getId() != null) {
@@ -65,7 +65,7 @@ public class EventResource {
} }
@PostMapping("/{id}/settle") @PostMapping("/{id}/settle")
@Secured({ AuthoritiesConstants.ADMIN }) @Secured({ AuthoritiesConstants.ADMIN, AuthoritiesConstants.COUNTER })
public ResponseEntity<Optional<Event>> settleEvent(@RequestBody Optional<Event> event) throws URISyntaxException { public ResponseEntity<Optional<Event>> settleEvent(@RequestBody Optional<Event> event) throws URISyntaxException {
event = eventService.settle(event.orElse(null)); event = eventService.settle(event.orElse(null));
return ResponseEntity.ok() return ResponseEntity.ok()
@@ -84,7 +84,7 @@ public class EventResource {
* @throws URISyntaxException if the Location URI syntax is incorrect. * @throws URISyntaxException if the Location URI syntax is incorrect.
*/ */
@PutMapping("/{id}") @PutMapping("/{id}")
@Secured({ AuthoritiesConstants.ADMIN }) @Secured({ AuthoritiesConstants.ADMIN, AuthoritiesConstants.COUNTER })
public ResponseEntity<Event> updateEvent(@PathVariable(value = "id", required = false) final Long id, @Valid @RequestBody Event event) public ResponseEntity<Event> updateEvent(@PathVariable(value = "id", required = false) final Long id, @Valid @RequestBody Event event)
throws URISyntaxException { throws URISyntaxException {
LOG.debug("REST request to update Event : {}, {}", id, event); 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. * or with status {@code 500 (Internal Server Error)} if the event couldn't be updated.
* @throws URISyntaxException if the Location URI syntax is incorrect. * @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" }) @PatchMapping(value = "/{id}", consumes = { "application/json", "application/merge-patch+json" })
public ResponseEntity<Event> partialUpdateEvent( public ResponseEntity<Event> partialUpdateEvent(
@PathVariable(value = "id", required = false) final Long id, @PathVariable(value = "id", required = false) final Long id,
@@ -50,7 +50,7 @@ public class TransactionResource {
* @throws URISyntaxException if the Location URI syntax is incorrect. * @throws URISyntaxException if the Location URI syntax is incorrect.
*/ */
@PostMapping("") @PostMapping("")
@Secured({ AuthoritiesConstants.ADMIN }) @Secured({ AuthoritiesConstants.ADMIN, AuthoritiesConstants.COUNTER })
public ResponseEntity<Transaction> createTransaction(@RequestBody Transaction transaction) throws URISyntaxException { public ResponseEntity<Transaction> createTransaction(@RequestBody Transaction transaction) throws URISyntaxException {
LOG.debug("REST request to save Transaction : {}", transaction); LOG.debug("REST request to save Transaction : {}", transaction);
if (transaction.getId() != null) { 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. * or with status {@code 500 (Internal Server Error)} if the transaction couldn't be updated.
* @throws URISyntaxException if the Location URI syntax is incorrect. * @throws URISyntaxException if the Location URI syntax is incorrect.
*/ */
@Secured({ AuthoritiesConstants.ADMIN }) @Secured({ AuthoritiesConstants.ADMIN, AuthoritiesConstants.COUNTER })
@PutMapping("/{id}") @PutMapping("/{id}")
public ResponseEntity<Transaction> updateTransaction( public ResponseEntity<Transaction> updateTransaction(
@PathVariable(value = "id", required = false) final Long id, @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. * or with status {@code 500 (Internal Server Error)} if the transaction couldn't be updated.
* @throws URISyntaxException if the Location URI syntax is incorrect. * @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" }) @PatchMapping(value = "/{id}", consumes = { "application/json", "application/merge-patch+json" })
public ResponseEntity<Transaction> partialUpdateTransaction( public ResponseEntity<Transaction> partialUpdateTransaction(
@PathVariable(value = "id", required = false) final Long id, @PathVariable(value = "id", required = false) final Long id,
@@ -45,7 +45,7 @@
<font-awesome-icon icon="plus"></font-awesome-icon>&nbsp;<span>Dołącz do wydarzenia</span> <font-awesome-icon icon="plus"></font-awesome-icon>&nbsp;<span>Dołącz do wydarzenia</span>
</button> </button>
</router-link> </router-link>
<button class="btn btn-primary float-right" v-if="hasAnyAuthority('ROLE_ADMIN')" @click="settle()"> <button class="btn btn-primary float-right" v-if="hasAnyAuthority(['ROLE_ADMIN', 'ROLE_COUNTER'])" @click="settle()">
<font-awesome-icon icon="sync"></font-awesome-icon> <span>Rozlicz wydarzenie</span> <font-awesome-icon icon="sync"></font-awesome-icon> <span>Rozlicz wydarzenie</span>
</button> </button>
<div class="table-responsive" v-if="event.registrations && event.registrations.length > 0"> <div class="table-responsive" v-if="event.registrations && event.registrations.length > 0">
@@ -77,7 +77,8 @@
class="btn btn-sm" class="btn btn-sm"
data-cy="entityDeleteButton" data-cy="entityDeleteButton"
v-if=" 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 registration.active !== false
" "
v-b-modal.removeEntity v-b-modal.removeEntity
@@ -40,7 +40,7 @@
custom custom
v-slot="{ navigate }" v-slot="{ navigate }"
> >
<button @click="navigate" class="btn btn-primary" v-if="hasAnyAuthority('ROLE_ADMIN')"> <button @click="navigate" class="btn btn-primary" v-if="hasAnyAuthority(['ROLE_ADMIN', 'ROLE_COUNTER'])">
<font-awesome-icon icon="pencil-alt"></font-awesome-icon>&nbsp;<span>Edit</span> <font-awesome-icon icon="pencil-alt"></font-awesome-icon>&nbsp;<span>Edit</span>
</button> </button>
</router-link> </router-link>
@@ -50,7 +50,7 @@
custom custom
v-slot="{ navigate }" v-slot="{ navigate }"
> >
<button @click="navigate" class="btn btn-primary" v-if="hasAnyAuthority('ROLE_ADMIN')"> <button @click="navigate" class="btn btn-primary" v-if="hasAnyAuthority(['ROLE_ADMIN', 'ROLE_COUNTER'])">
<font-awesome-icon icon="pencil-alt"></font-awesome-icon>&nbsp;<span>Create opposite transaction</span> <font-awesome-icon icon="pencil-alt"></font-awesome-icon>&nbsp;<span>Create opposite transaction</span>
</button> </button>
</router-link> </router-link>
@@ -6,7 +6,12 @@
<button class="btn btn-info mr-2" @click="handleSyncList" :disabled="isFetching"> <button class="btn btn-info mr-2" @click="handleSyncList" :disabled="isFetching">
<font-awesome-icon icon="sync" :spin="isFetching"></font-awesome-icon> <span>Refresh list</span> <font-awesome-icon icon="sync" :spin="isFetching"></font-awesome-icon> <span>Refresh list</span>
</button> </button>
<router-link :to="{ name: 'TransactionCreate' }" custom v-slot="{ navigate }" v-if="hasAnyAuthority('ROLE_ADMIN')"> <router-link
:to="{ name: 'TransactionCreate' }"
custom
v-slot="{ navigate }"
v-if="hasAnyAuthority(['ROLE_ADMIN', 'ROLE_COUNTER'])"
>
<button <button
@click="navigate" @click="navigate"
id="jh-create-entity" id="jh-create-entity"
@@ -94,7 +99,7 @@
:to="{ name: 'TransactionEdit', params: { transactionId: transaction.id } }" :to="{ name: 'TransactionEdit', params: { transactionId: transaction.id } }"
custom custom
v-slot="{ navigate }" v-slot="{ navigate }"
v-if="hasAnyAuthority('ROLE_ADMIN')" v-if="hasAnyAuthority(['ROLE_ADMIN', 'ROLE_COUNTER'])"
> >
<button @click="navigate" class="btn btn-primary btn-sm edit" data-cy="entityEditButton"> <button @click="navigate" class="btn btn-primary btn-sm edit" data-cy="entityEditButton">
<font-awesome-icon icon="pencil-alt"></font-awesome-icon> <font-awesome-icon icon="pencil-alt"></font-awesome-icon>