From 54ec769a9e1013c68742abed9c09a2f65d606226 Mon Sep 17 00:00:00 2001 From: shadowik Date: Sun, 18 Jun 2023 20:22:55 +0400 Subject: [PATCH] Lab 6 Vue --- .../configuration/SecurityConfiguration.java | 21 +++++++++++++++---- .../demo/util/error/AdviceController.java | 11 +++++----- .../util/validation/ValidationException.java | 4 ++++ src/main/resources/static/style.css | 5 +++-- .../resources/templates/MastersOrders.html | 2 +- src/main/resources/templates/OrderPage.html | 6 +++--- .../resources/templates/ProductCreate.html | 4 ++-- src/main/resources/templates/Products.html | 4 ++-- src/main/resources/templates/UserPage.html | 8 +++---- .../resources/templates/UserProducts.html | 4 ++-- src/main/resources/templates/default.html | 11 ++++++++-- src/main/resources/templates/error.html | 13 ++++++++++++ src/main/resources/templates/login.html | 4 ++-- src/main/resources/templates/singup.html | 8 +++---- 14 files changed, 71 insertions(+), 34 deletions(-) create mode 100644 src/main/resources/templates/error.html diff --git a/src/main/java/com/example/demo/configuration/SecurityConfiguration.java b/src/main/java/com/example/demo/configuration/SecurityConfiguration.java index 60609dd..b4a3dd5 100644 --- a/src/main/java/com/example/demo/configuration/SecurityConfiguration.java +++ b/src/main/java/com/example/demo/configuration/SecurityConfiguration.java @@ -17,6 +17,7 @@ import org.springframework.security.config.annotation.web.configuration.EnableWe import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; import org.springframework.security.web.SecurityFilterChain; + @Configuration @EnableWebSecurity @EnableMethodSecurity( @@ -48,6 +49,7 @@ public class SecurityConfiguration { .authorizeHttpRequests() .requestMatchers(MasterSignupMvcController.SIGNUP_URL).permitAll() .requestMatchers(HttpMethod.GET, LOGIN_URL).permitAll() + .requestMatchers("/product").permitAll() .anyRequest().authenticated() .and() .formLogin() @@ -68,9 +70,20 @@ public class SecurityConfiguration { @Bean public WebSecurityCustomizer webSecurityCustomizer() { return (web) -> web.ignoring() - .requestMatchers("/css/**") - .requestMatchers("/js/**") - .requestMatchers("/templates/**") - .requestMatchers("/webjars/**"); + .requestMatchers(HttpMethod.OPTIONS, "/**") + .requestMatchers("/*.js") + .requestMatchers("/*.html") + .requestMatchers("/*.css") + .requestMatchers("/assets/**") + .requestMatchers("/favicon.ico") + .requestMatchers("/.js", "/.css") + .requestMatchers("/swagger-ui/index.html") + .requestMatchers("/webjars/**") + .requestMatchers("/swagger-resources/**") + .requestMatchers("/v3/api-docs/**") + .requestMatchers("/h2-console"); + } + + } \ No newline at end of file diff --git a/src/main/java/com/example/demo/util/error/AdviceController.java b/src/main/java/com/example/demo/util/error/AdviceController.java index bf350e4..72bc492 100644 --- a/src/main/java/com/example/demo/util/error/AdviceController.java +++ b/src/main/java/com/example/demo/util/error/AdviceController.java @@ -1,7 +1,8 @@ package com.example.demo.util.error; + +import com.example.demo.master.Master; import com.example.demo.master.MasterNotFoundException; -import com.example.demo.order.Order; import com.example.demo.order.OrderNotFoundException; import com.example.demo.product.ProductNotFoundException; import com.example.demo.util.validation.ValidationException; @@ -11,17 +12,15 @@ import org.springframework.http.ResponseEntity; import org.springframework.web.bind.MethodArgumentNotValidException; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; - - import java.util.stream.Collectors; -@ControllerAdvice + public class AdviceController { @ExceptionHandler({ MasterNotFoundException.class, - ProductNotFoundException.class, OrderNotFoundException.class, - ValidationException.class, + ProductNotFoundException.class, + ValidationException.class }) public ResponseEntity handleException(Throwable e) { return new ResponseEntity<>(e.getMessage(), HttpStatus.BAD_REQUEST); diff --git a/src/main/java/com/example/demo/util/validation/ValidationException.java b/src/main/java/com/example/demo/util/validation/ValidationException.java index d058613..c458889 100644 --- a/src/main/java/com/example/demo/util/validation/ValidationException.java +++ b/src/main/java/com/example/demo/util/validation/ValidationException.java @@ -6,4 +6,8 @@ public class ValidationException extends RuntimeException { public ValidationException(Set errors) { super(String.join("\n", errors)); } + + public ValidationException(String error) { + super(error); + } } diff --git a/src/main/resources/static/style.css b/src/main/resources/static/style.css index 07b9627..87c0bc1 100644 --- a/src/main/resources/static/style.css +++ b/src/main/resources/static/style.css @@ -21,5 +21,6 @@ form { } .product-div { - background: #e874ac; -} \ No newline at end of file + background: #e874ac !important; +} + diff --git a/src/main/resources/templates/MastersOrders.html b/src/main/resources/templates/MastersOrders.html index b97f8ff..c6877c0 100644 --- a/src/main/resources/templates/MastersOrders.html +++ b/src/main/resources/templates/MastersOrders.html @@ -22,7 +22,7 @@
- diff --git a/src/main/resources/templates/OrderPage.html b/src/main/resources/templates/OrderPage.html index 8a2c182..39667d2 100644 --- a/src/main/resources/templates/OrderPage.html +++ b/src/main/resources/templates/OrderPage.html @@ -24,10 +24,10 @@
-

+

-

+

@@ -35,7 +35,7 @@
-

+

diff --git a/src/main/resources/templates/ProductCreate.html b/src/main/resources/templates/ProductCreate.html index 7e617c9..4985e20 100644 --- a/src/main/resources/templates/ProductCreate.html +++ b/src/main/resources/templates/ProductCreate.html @@ -19,8 +19,8 @@
- - + +
diff --git a/src/main/resources/templates/Products.html b/src/main/resources/templates/Products.html index 636c83a..446e9e6 100644 --- a/src/main/resources/templates/Products.html +++ b/src/main/resources/templates/Products.html @@ -22,10 +22,10 @@
-

+

-

+

diff --git a/src/main/resources/templates/UserPage.html b/src/main/resources/templates/UserPage.html index 2475208..25ecd49 100644 --- a/src/main/resources/templates/UserPage.html +++ b/src/main/resources/templates/UserPage.html @@ -19,19 +19,19 @@
-
-
-
-
diff --git a/src/main/resources/templates/UserProducts.html b/src/main/resources/templates/UserProducts.html index bac7780..204df67 100644 --- a/src/main/resources/templates/UserProducts.html +++ b/src/main/resources/templates/UserProducts.html @@ -23,10 +23,10 @@
-

+

-

+

Edit diff --git a/src/main/resources/templates/default.html b/src/main/resources/templates/default.html index 8aff8a2..904ce95 100644 --- a/src/main/resources/templates/default.html +++ b/src/main/resources/templates/default.html @@ -7,6 +7,13 @@ Title + + @@ -17,10 +24,10 @@ integrity="sha384-Y4oOpwW3duJdCWv5ly8SCFYWqFDsfob/3GkgExXKV4idmbt98QcxXYs9UoXAB7BZ" crossorigin="anonymous"> - +