diff --git a/src/main/java/ru/ulstu/configuration/SecurityConfiguration.java b/src/main/java/ru/ulstu/configuration/SecurityConfiguration.java index 2feb8ba..5eb7220 100644 --- a/src/main/java/ru/ulstu/configuration/SecurityConfiguration.java +++ b/src/main/java/ru/ulstu/configuration/SecurityConfiguration.java @@ -16,7 +16,7 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.web.authentication.AuthenticationFailureHandler; import org.springframework.security.web.authentication.AuthenticationSuccessHandler; import org.springframework.security.web.authentication.logout.LogoutSuccessHandler; -import ru.ulstu.core.model.RestAuthenticationFailureHandler; +import ru.ulstu.core.model.AuthFailureHandler; import ru.ulstu.user.controller.UserController; import ru.ulstu.user.model.UserRoleConstants; import ru.ulstu.user.service.UserService; @@ -44,7 +44,7 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter { AuthenticationSuccessHandler authenticationSuccessHandler, LogoutSuccessHandler logoutSuccessHandler, ApplicationProperties applicationProperties, - RestAuthenticationFailureHandler authenticationFailureHandler) { + AuthFailureHandler authenticationFailureHandler) { this.userService = userService; this.bCryptPasswordEncoder = bCryptPasswordEncoder; this.authenticationSuccessHandler = authenticationSuccessHandler; @@ -71,6 +71,7 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter { .antMatchers(UserController.ACTIVATE_URL).permitAll() .antMatchers(Constants.PASSWORD_RESET_REQUEST_PAGE).permitAll() .antMatchers(Constants.PASSWORD_RESET_PAGE).permitAll() + .antMatchers("/users/block").permitAll() .antMatchers(UserController.URL + UserController.REGISTER_URL).permitAll() .antMatchers(UserController.URL + UserController.ACTIVATE_URL).permitAll() .antMatchers(UserController.URL + UserController.PASSWORD_RESET_REQUEST_URL).permitAll() diff --git a/src/main/java/ru/ulstu/core/controller/AdviceController.java b/src/main/java/ru/ulstu/core/controller/AdviceController.java index 78a7771..f89001a 100644 --- a/src/main/java/ru/ulstu/core/controller/AdviceController.java +++ b/src/main/java/ru/ulstu/core/controller/AdviceController.java @@ -12,7 +12,6 @@ import ru.ulstu.core.model.ErrorConstants; import ru.ulstu.core.model.response.Response; import ru.ulstu.core.model.response.ResponseExtended; import ru.ulstu.user.error.UserActivationError; -import ru.ulstu.user.error.UserBlockedException; import ru.ulstu.user.error.UserEmailExistsException; import ru.ulstu.user.error.UserIdExistsException; import ru.ulstu.user.error.UserIsUndeadException; diff --git a/src/main/java/ru/ulstu/core/model/RestAuthenticationFailureHandler.java b/src/main/java/ru/ulstu/core/model/AuthFailureHandler.java similarity index 66% rename from src/main/java/ru/ulstu/core/model/RestAuthenticationFailureHandler.java rename to src/main/java/ru/ulstu/core/model/AuthFailureHandler.java index 4e07d0d..8b6bd9d 100644 --- a/src/main/java/ru/ulstu/core/model/RestAuthenticationFailureHandler.java +++ b/src/main/java/ru/ulstu/core/model/AuthFailureHandler.java @@ -3,18 +3,19 @@ package ru.ulstu.core.model; import org.springframework.security.core.AuthenticationException; import org.springframework.security.web.authentication.AuthenticationFailureHandler; import org.springframework.stereotype.Component; +import ru.ulstu.user.error.UserBlockedException; -import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; @Component -public class RestAuthenticationFailureHandler implements AuthenticationFailureHandler { +public class AuthFailureHandler implements AuthenticationFailureHandler { @Override public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, - AuthenticationException ex) throws IOException, ServletException { - - response.sendRedirect("/login.html?error=fail"); + AuthenticationException ex) throws IOException { + if (ex.getClass() == UserBlockedException.class) { + response.sendRedirect("/users/block"); + } } } \ No newline at end of file diff --git a/src/main/java/ru/ulstu/user/controller/UserMvcController.java b/src/main/java/ru/ulstu/user/controller/UserMvcController.java index f0a28d8..bf84176 100644 --- a/src/main/java/ru/ulstu/user/controller/UserMvcController.java +++ b/src/main/java/ru/ulstu/user/controller/UserMvcController.java @@ -74,4 +74,8 @@ public class UserMvcController extends OdinController { @GetMapping("/pings") public void getPings() { } + + @GetMapping("/block") + public void getBlock() { + } } diff --git a/src/main/resources/db/changelog-20190531_000002-schema.xml b/src/main/resources/db/changelog-20190607_000002-schema.xml similarity index 100% rename from src/main/resources/db/changelog-20190531_000002-schema.xml rename to src/main/resources/db/changelog-20190607_000002-schema.xml diff --git a/src/main/resources/templates/users/block.html b/src/main/resources/templates/users/block.html new file mode 100644 index 0000000..3b27494 --- /dev/null +++ b/src/main/resources/templates/users/block.html @@ -0,0 +1,21 @@ + + + + + +
+
+
+
+
+

Ваш аккаунт заблокирован

+

Вернуться на страницу авторизации

+
+
+
+
+
+ + \ No newline at end of file