From a6731fcdfc46815301f04c0ba0d772dfd4a9f28c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C5=82awek=20Zatorski?= Date: Mon, 18 Nov 2024 17:20:51 +0100 Subject: [PATCH] aa --- .../event/web/rest/ChargeResource.java | 3 +++ .../event/web/rest/EventResource.java | 7 ++++++ .../web/rest/TransactionItemResource.java | 3 +++ .../event/web/rest/TransactionResource.java | 6 +++++ .../event/web/rest/UserAccountResource.java | 6 +++++ .../app/entities/event/event-details.vue | 2 +- .../transaction/transaction.component.ts | 15 ++++++++++++ .../app/entities/transaction/transaction.vue | 8 ++++++- src/main/webapp/app/router/entities.ts | 24 +++++++++---------- 9 files changed, 60 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/sasiedzi/event/web/rest/ChargeResource.java b/src/main/java/com/sasiedzi/event/web/rest/ChargeResource.java index 46f4151..deeb799 100644 --- a/src/main/java/com/sasiedzi/event/web/rest/ChargeResource.java +++ b/src/main/java/com/sasiedzi/event/web/rest/ChargeResource.java @@ -2,6 +2,7 @@ package com.sasiedzi.event.web.rest; import com.sasiedzi.event.domain.Charge; import com.sasiedzi.event.repository.ChargeRepository; +import com.sasiedzi.event.security.AuthoritiesConstants; import com.sasiedzi.event.web.rest.errors.BadRequestAlertException; import jakarta.validation.Valid; import jakarta.validation.constraints.NotNull; @@ -14,6 +15,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.ResponseEntity; +import org.springframework.security.access.annotation.Secured; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import tech.jhipster.web.util.HeaderUtil; @@ -25,6 +27,7 @@ import tech.jhipster.web.util.ResponseUtil; @RestController @RequestMapping("/api/charges") @Transactional +@Secured({ AuthoritiesConstants.ADMIN }) public class ChargeResource { private static final Logger LOG = LoggerFactory.getLogger(ChargeResource.class); 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 0d13650..62553ec 100644 --- a/src/main/java/com/sasiedzi/event/web/rest/EventResource.java +++ b/src/main/java/com/sasiedzi/event/web/rest/EventResource.java @@ -2,6 +2,7 @@ package com.sasiedzi.event.web.rest; import com.sasiedzi.event.domain.Event; import com.sasiedzi.event.repository.EventRepository; +import com.sasiedzi.event.security.AuthoritiesConstants; import com.sasiedzi.event.service.EventService; import com.sasiedzi.event.web.rest.errors.BadRequestAlertException; import jakarta.validation.Valid; @@ -15,6 +16,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.ResponseEntity; +import org.springframework.security.access.annotation.Secured; import org.springframework.web.bind.annotation.*; import tech.jhipster.web.util.HeaderUtil; import tech.jhipster.web.util.ResponseUtil; @@ -50,6 +52,7 @@ public class EventResource { * @throws URISyntaxException if the Location URI syntax is incorrect. */ @PostMapping("") + @Secured({ AuthoritiesConstants.ADMIN }) public ResponseEntity createEvent(@Valid @RequestBody Event event) throws URISyntaxException { LOG.debug("REST request to save Event : {}", event); if (event.getId() != null) { @@ -62,6 +65,7 @@ public class EventResource { } @PostMapping("/{id}/settle") + @Secured({ AuthoritiesConstants.ADMIN }) public ResponseEntity> settleEvent(@RequestBody Optional event) throws URISyntaxException { event = eventService.settle(event.orElse(null)); return ResponseEntity.ok() @@ -80,6 +84,7 @@ public class EventResource { * @throws URISyntaxException if the Location URI syntax is incorrect. */ @PutMapping("/{id}") + @Secured({ AuthoritiesConstants.ADMIN }) 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); @@ -111,6 +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 }) @PatchMapping(value = "/{id}", consumes = { "application/json", "application/merge-patch+json" }) public ResponseEntity partialUpdateEvent( @PathVariable(value = "id", required = false) final Long id, @@ -167,6 +173,7 @@ public class EventResource { * @return the {@link ResponseEntity} with status {@code 204 (NO_CONTENT)}. */ @DeleteMapping("/{id}") + @Secured({ AuthoritiesConstants.ADMIN }) public ResponseEntity deleteEvent(@PathVariable("id") Long id) { LOG.debug("REST request to delete Event : {}", id); eventService.delete(id); diff --git a/src/main/java/com/sasiedzi/event/web/rest/TransactionItemResource.java b/src/main/java/com/sasiedzi/event/web/rest/TransactionItemResource.java index 14617dd..743edd4 100644 --- a/src/main/java/com/sasiedzi/event/web/rest/TransactionItemResource.java +++ b/src/main/java/com/sasiedzi/event/web/rest/TransactionItemResource.java @@ -2,6 +2,7 @@ package com.sasiedzi.event.web.rest; import com.sasiedzi.event.domain.TransactionItem; import com.sasiedzi.event.repository.TransactionItemRepository; +import com.sasiedzi.event.security.AuthoritiesConstants; import com.sasiedzi.event.web.rest.errors.BadRequestAlertException; import java.net.URI; import java.net.URISyntaxException; @@ -12,6 +13,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.ResponseEntity; +import org.springframework.security.access.annotation.Secured; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import tech.jhipster.web.util.HeaderUtil; @@ -23,6 +25,7 @@ import tech.jhipster.web.util.ResponseUtil; @RestController @RequestMapping("/api/transaction-items") @Transactional +@Secured({ AuthoritiesConstants.ADMIN }) public class TransactionItemResource { private static final Logger LOG = LoggerFactory.getLogger(TransactionItemResource.class); 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 df8907e..d8ecb96 100644 --- a/src/main/java/com/sasiedzi/event/web/rest/TransactionResource.java +++ b/src/main/java/com/sasiedzi/event/web/rest/TransactionResource.java @@ -2,6 +2,7 @@ package com.sasiedzi.event.web.rest; import com.sasiedzi.event.domain.*; import com.sasiedzi.event.repository.TransactionRepository; +import com.sasiedzi.event.security.AuthoritiesConstants; import com.sasiedzi.event.web.rest.errors.BadRequestAlertException; import java.math.BigDecimal; import java.net.URI; @@ -12,6 +13,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.ResponseEntity; +import org.springframework.security.access.annotation.Secured; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import tech.jhipster.web.util.HeaderUtil; @@ -46,6 +48,7 @@ public class TransactionResource { * @throws URISyntaxException if the Location URI syntax is incorrect. */ @PostMapping("") + @Secured({ AuthoritiesConstants.ADMIN }) public ResponseEntity createTransaction(@RequestBody Transaction transaction) throws URISyntaxException { LOG.debug("REST request to save Transaction : {}", transaction); if (transaction.getId() != null) { @@ -67,6 +70,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 }) @PutMapping("/{id}") public ResponseEntity updateTransaction( @PathVariable(value = "id", required = false) final Long id, @@ -101,6 +105,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 }) @PatchMapping(value = "/{id}", consumes = { "application/json", "application/merge-patch+json" }) public ResponseEntity partialUpdateTransaction( @PathVariable(value = "id", required = false) final Long id, @@ -277,6 +282,7 @@ public class TransactionResource { * @return the {@link ResponseEntity} with status {@code 204 (NO_CONTENT)}. */ @DeleteMapping("/{id}") + @Secured({ AuthoritiesConstants.ADMIN }) public ResponseEntity deleteTransaction(@PathVariable("id") Long id) { LOG.debug("REST request to delete Transaction : {}", id); transactionRepository.deleteById(id); diff --git a/src/main/java/com/sasiedzi/event/web/rest/UserAccountResource.java b/src/main/java/com/sasiedzi/event/web/rest/UserAccountResource.java index cf27f67..c7a4837 100644 --- a/src/main/java/com/sasiedzi/event/web/rest/UserAccountResource.java +++ b/src/main/java/com/sasiedzi/event/web/rest/UserAccountResource.java @@ -4,6 +4,7 @@ import com.sasiedzi.event.domain.CurrentUserHolder; import com.sasiedzi.event.domain.User; import com.sasiedzi.event.domain.UserAccount; import com.sasiedzi.event.repository.UserAccountRepository; +import com.sasiedzi.event.security.AuthoritiesConstants; import com.sasiedzi.event.service.EventService; import com.sasiedzi.event.service.UserService; import com.sasiedzi.event.web.rest.errors.BadRequestAlertException; @@ -17,6 +18,7 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.ResponseEntity; +import org.springframework.security.access.annotation.Secured; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.transaction.annotation.Transactional; @@ -53,6 +55,7 @@ public class UserAccountResource { * @throws URISyntaxException if the Location URI syntax is incorrect. */ @PostMapping("") + @Secured({ AuthoritiesConstants.ADMIN }) public ResponseEntity createUserAccount(@RequestBody UserAccount userAccount) throws URISyntaxException { LOG.debug("REST request to save UserAccount : {}", userAccount); if (userAccount.getId() != null) { @@ -74,6 +77,7 @@ public class UserAccountResource { * or with status {@code 500 (Internal Server Error)} if the userAccount couldn't be updated. * @throws URISyntaxException if the Location URI syntax is incorrect. */ + @Secured({ AuthoritiesConstants.ADMIN }) @PutMapping("/{id}") public ResponseEntity updateUserAccount( @PathVariable(value = "id", required = false) final Long id, @@ -108,6 +112,7 @@ public class UserAccountResource { * or with status {@code 500 (Internal Server Error)} if the userAccount couldn't be updated. * @throws URISyntaxException if the Location URI syntax is incorrect. */ + @Secured({ AuthoritiesConstants.ADMIN }) @PatchMapping(value = "/{id}", consumes = { "application/json", "application/merge-patch+json" }) public ResponseEntity partialUpdateUserAccount( @PathVariable(value = "id", required = false) final Long id, @@ -188,6 +193,7 @@ public class UserAccountResource { * @return the {@link ResponseEntity} with status {@code 204 (NO_CONTENT)}. */ @DeleteMapping("/{id}") + @Secured({ AuthoritiesConstants.ADMIN }) public ResponseEntity deleteUserAccount(@PathVariable("id") Long id) { LOG.debug("REST request to delete UserAccount : {}", id); userAccountRepository.deleteById(id); diff --git a/src/main/webapp/app/entities/event/event-details.vue b/src/main/webapp/app/entities/event/event-details.vue index 90cc162..5b72904 100644 --- a/src/main/webapp/app/entities/event/event-details.vue +++ b/src/main/webapp/app/entities/event/event-details.vue @@ -1,6 +1,6 @@