#95 block user html
This commit is contained in:
parent
fb23f182de
commit
96d166d031
@ -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()
|
||||
|
@ -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;
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
@ -74,4 +74,8 @@ public class UserMvcController extends OdinController<UserListDto, UserDto> {
|
||||
@GetMapping("/pings")
|
||||
public void getPings() {
|
||||
}
|
||||
|
||||
@GetMapping("/block")
|
||||
public void getBlock() {
|
||||
}
|
||||
}
|
||||
|
21
src/main/resources/templates/users/block.html
Normal file
21
src/main/resources/templates/users/block.html
Normal file
@ -0,0 +1,21 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
layout:decorator="default">
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container" layout:fragment="content">
|
||||
<section id="services">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-lg-12 text-center">
|
||||
<h2 class="section-heading text-uppercase">Ваш аккаунт заблокирован</h2>
|
||||
<a href="/"><h3>Вернуться на страницу авторизации</h3></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user