From 93582c2f07a9203a02722bd83a4e7ee23acad51e Mon Sep 17 00:00:00 2001 From: gsd Date: Fri, 20 Oct 2023 15:14:25 +0300 Subject: [PATCH] new front update 5 fix crypt --- .../controllers/other/CryptoController.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main/java/app/controllers/other/CryptoController.java b/src/main/java/app/controllers/other/CryptoController.java index a5e404c..9c35efd 100644 --- a/src/main/java/app/controllers/other/CryptoController.java +++ b/src/main/java/app/controllers/other/CryptoController.java @@ -3,12 +3,13 @@ package app.controllers.other; import app.annotations.interfaces.CheckPermitionFlag; import app.annotations.interfaces.CheckWebAccess; import app.utils.CryptedCookie; +import jakarta.servlet.http.HttpServletRequest; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import java.util.HashMap; import java.util.Map; -import java.util.stream.Collectors; @RestController @RequestMapping("/api/crypto") @@ -20,10 +21,17 @@ public class CryptoController { this.cryptedCookie = cryptedCookie; } - @GetMapping @CheckWebAccess @CheckPermitionFlag - public HashMap crypt(@RequestBody HashMap need_crypt) { + @RequestMapping(method = RequestMethod.OPTIONS) + public ResponseEntity checkPermission(HttpServletRequest httpServletRequest) { + return ResponseEntity.ok().build(); + } + + @PostMapping("/crypt") + @CheckWebAccess + @CheckPermitionFlag + public HashMap crypt(HttpServletRequest httpServletRequest, @RequestBody HashMap need_crypt) { return new HashMap<>() {{ need_crypt.entrySet().stream() .map((item) -> Map.of("key", item.getKey(), "value", cryptedCookie.Hashed(item.getValue()))) @@ -32,10 +40,10 @@ public class CryptoController { }}; } - @PostMapping + @PostMapping("/decrypt") @CheckWebAccess @CheckPermitionFlag - public HashMap decrypt(@RequestBody HashMap need_decrypt) { + public HashMap decrypt(HttpServletRequest httpServletRequest, @RequestBody HashMap need_decrypt) { return new HashMap<>() {{ need_decrypt.entrySet().stream() .map((item) -> Map.of("key", item.getKey(), "value", cryptedCookie.ReadCh(item.getValue())))