Another fixation.
This commit is contained in:
parent
1ba8b942ea
commit
8803176103
@ -26,9 +26,6 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
|
|||||||
private static final String LOGIN_URL = "/login";
|
private static final String LOGIN_URL = "/login";
|
||||||
private final GameClientService clientService;
|
private final GameClientService clientService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private UserDetailsService userDetailsService;
|
|
||||||
|
|
||||||
public SecurityConfiguration(GameClientService clientService) {
|
public SecurityConfiguration(GameClientService clientService) {
|
||||||
this.clientService = clientService;
|
this.clientService = clientService;
|
||||||
createAdminOnStartup();
|
createAdminOnStartup();
|
||||||
|
@ -16,7 +16,7 @@ public class UserSignupDto {
|
|||||||
private String email;
|
private String email;
|
||||||
|
|
||||||
@NotBlank
|
@NotBlank
|
||||||
private Integer balance;
|
private String balance;
|
||||||
|
|
||||||
@NotBlank
|
@NotBlank
|
||||||
@Size(min = 6, max = 64)
|
@Size(min = 6, max = 64)
|
||||||
@ -38,7 +38,7 @@ public class UserSignupDto {
|
|||||||
this.email = email;
|
this.email = email;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBalance(Integer balance) {
|
public void setBalance(String balance) {
|
||||||
this.balance = balance;
|
this.balance = balance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ public class UserSignupDto {
|
|||||||
return email;
|
return email;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getBalance() {
|
public String getBalance() {
|
||||||
return balance;
|
return balance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import premium_store.service.TankService;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
|
@CrossOrigin
|
||||||
@RequestMapping(WebConfiguration.REST_API + "/client")
|
@RequestMapping(WebConfiguration.REST_API + "/client")
|
||||||
public class GameClientController {
|
public class GameClientController {
|
||||||
private final GameClientService gameClientService;
|
private final GameClientService gameClientService;
|
||||||
|
@ -2,9 +2,6 @@ package premium_store.controller.controller;
|
|||||||
|
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.security.access.annotation.Secured;
|
import org.springframework.security.access.annotation.Secured;
|
||||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
|
||||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.validation.BindingResult;
|
import org.springframework.validation.BindingResult;
|
||||||
@ -15,31 +12,29 @@ import premium_store.service.GameClientService;
|
|||||||
import premium_store.service.TankService;
|
import premium_store.service.TankService;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.validation.ValidationException;
|
|
||||||
import java.security.Principal;
|
import java.security.Principal;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/clients")
|
@RequestMapping("/client")
|
||||||
public class ClientMvcController {
|
public class GameClientMvcController {
|
||||||
private final GameClientService gameClientService;
|
private final GameClientService gameClientService;
|
||||||
private final TankService tankService;
|
private final TankService tankService;
|
||||||
|
|
||||||
public ClientMvcController(GameClientService gameClientService, TankService tankService){
|
public GameClientMvcController(GameClientService gameClientService, TankService tankService){
|
||||||
this.gameClientService = gameClientService;
|
this.gameClientService = gameClientService;
|
||||||
this.tankService = tankService;
|
this.tankService = tankService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping({"/showUpdate"})
|
||||||
public String showUpdateUserForm(Principal principal, Model model) {
|
public String showUpdateUserForm(Principal principal, Model model) {
|
||||||
ClientDTO clientDTO = new ClientDTO(gameClientService.findByLogin(principal.getName()));
|
ClientDTO clientDTO = new ClientDTO(gameClientService.findByLogin(principal.getName()));
|
||||||
model.addAttribute("clientDTO", clientDTO);
|
model.addAttribute("clientDTO", clientDTO);
|
||||||
return "client-edit";
|
return "client-edit";
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping({"/getClients"})
|
||||||
@Secured({UserRole.AsString.ADMIN})
|
@Secured({UserRole.AsString.ADMIN})
|
||||||
public String getClients(@RequestParam(defaultValue = "1") int page,
|
public String getClients(@RequestParam(defaultValue = "1") int page,
|
||||||
@RequestParam(defaultValue = "5") int size,
|
@RequestParam(defaultValue = "5") int size,
|
||||||
@ -62,7 +57,6 @@ public class ClientMvcController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(value = {"/edit", "/edit/{id}"})
|
@GetMapping(value = {"/edit", "/edit/{id}"})
|
||||||
@PostMapping
|
|
||||||
public String editClient(@ModelAttribute @Valid ClientDTO userDto,
|
public String editClient(@ModelAttribute @Valid ClientDTO userDto,
|
||||||
BindingResult bindingResult,
|
BindingResult bindingResult,
|
||||||
Model model) {
|
Model model) {
|
@ -1,14 +1,10 @@
|
|||||||
package premium_store.controller.controller;
|
package premium_store.controller.controller;
|
||||||
|
|
||||||
import net.bytebuddy.implementation.bind.MethodDelegationBinder;
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.validation.BindingResult;
|
import org.springframework.validation.BindingResult;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import premium_store.controller.DTO.FullNationDTO;
|
|
||||||
import premium_store.controller.DTO.LevelDTO;
|
import premium_store.controller.DTO.LevelDTO;
|
||||||
import premium_store.controller.DTO.SimpleNationDTO;
|
|
||||||
import premium_store.service.NationService;
|
|
||||||
import premium_store.service.TankLevelService;
|
import premium_store.service.TankLevelService;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
@ -41,12 +41,11 @@ public class UserSignupMvcController {
|
|||||||
return "signup";
|
return "signup";
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
final GameClient client = clientService.addClient(userSignupDto.getLogin(), userSignupDto.getEmail(), userSignupDto.getPassword(), userSignupDto.getBalance(), userSignupDto.getPasswordConfirm(), UserRole.USER);
|
final GameClient client = clientService.addClient(userSignupDto.getLogin(), userSignupDto.getEmail(), userSignupDto.getPassword(), Integer.parseInt(userSignupDto.getBalance()), userSignupDto.getPasswordConfirm());
|
||||||
return "redirect:/login?created=" + client.getLogin();
|
return "redirect:/login?created=" + client.getLogin();
|
||||||
} catch (ValidationException e) {
|
} catch (ValidationException e) {
|
||||||
model.addAttribute("errors", e.getMessage());
|
model.addAttribute("errors", e.getMessage());
|
||||||
return "signup";
|
return "signup";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
Список существующих клиентов:
|
Список существующих клиентов:
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
<div th:each="client, iterator: ${clients}">
|
<div th:each="client, iterator: ${users}">
|
||||||
<div class="client-card">
|
<div class="client-card">
|
||||||
<p class="client-attribute" th:text="'Номер: ' + ${client.id}"/>
|
<p class="client-attribute" th:text="'Номер: ' + ${client.id}"/>
|
||||||
<p class="client-attribute" th:text="'Никнейм: ' + ${client.nickName}"/>
|
<p class="client-attribute" th:text="'Никнейм: ' + ${client.nickName}"/>
|
||||||
@ -49,6 +49,14 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div th:if="${totalPages > 0}" class="pagination">
|
||||||
|
<span style="float: left; padding: 5px 5px;">Страницы:</span>
|
||||||
|
<a th:each="page : ${pages}"
|
||||||
|
th:href="@{/users(page=${page}, size=${users.size})}"
|
||||||
|
th:text="${page}"
|
||||||
|
th:class="${page == users.number + 1} ? active">
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<html lang="ru"
|
<html lang="ru"
|
||||||
xmlns:th="http://www.thymeleaf.org"
|
xmlns:th="http://www.thymeleaf.org"
|
||||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||||
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity6">
|
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8"/>
|
<meta charset="UTF-8"/>
|
||||||
<title>Премиум магазин</title>
|
<title>Премиум магазин</title>
|
||||||
@ -37,7 +37,7 @@
|
|||||||
th:classappend="${#strings.equals(activeLink, '/nation')} ? 'active' : ''">Обзор наций
|
th:classappend="${#strings.equals(activeLink, '/nation')} ? 'active' : ''">Обзор наций
|
||||||
</a>
|
</a>
|
||||||
<a class="nav-link btn border border-3 border-dark fs-4 lh-15 Button_Main_Group text-dark" href="/client"
|
<a class="nav-link btn border border-3 border-dark fs-4 lh-15 Button_Main_Group text-dark" href="/client"
|
||||||
th:classappend="${#strings.equals(activeLink, '/client')} ? 'active' : ''">Обзор клиентов
|
th:classappend="${#strings.equals(activeLink, '/clients')} ? 'active' : ''">Обзор клиентов
|
||||||
</a>
|
</a>
|
||||||
<a class="nav-link btn border border-3 border-dark fs-4 lh-15 Button_Main_Group text-dark" href="/logout">
|
<a class="nav-link btn border border-3 border-dark fs-4 lh-15 Button_Main_Group text-dark" href="/logout">
|
||||||
Выход(<span th:text="${#authentication.name}"></span>)
|
Выход(<span th:text="${#authentication.name}"></span>)
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div th:each="level, iterator: ${levels}">
|
<div th:each="level, iterator: ${levels}">
|
||||||
<div class="level-card">
|
<div class="level-card">
|
||||||
<p class="level-attribute" th:text="'Нация: ' + ${level.id}"/>
|
<p class="level-attribute" th:text="'Номер: ' + ${level.id}"/>
|
||||||
<p class="level-attribute" th:text="'Уровень: ' + ${level.level}"/>
|
<p class="level-attribute" th:text="'Уровень: ' + ${level.level}"/>
|
||||||
<div class='level-button-group'>
|
<div class='level-button-group'>
|
||||||
<form th:action="@{/level/edit/{id}(id=${level.id})}" method="get">
|
<form th:action="@{/level/edit/{id}(id=${level.id})}" method="get">
|
||||||
|
@ -1,33 +1,34 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en"
|
<html lang="en"
|
||||||
xmlns:th="http://www.thymeleaf.org"
|
xmlns:th="http://www.thymeleaf.org"
|
||||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
|
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||||
|
layout:decorate="~{default}">
|
||||||
<head>
|
<head>
|
||||||
<script type="text/javascript" src="/webjars/jquery/3.6.0/jquery.min.js"></script>
|
<script type="text/javascript" src="/webjars/jquery/3.6.0/jquery.min.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="container" layout:fragment="content">
|
<div class="container" layout:fragment="content">
|
||||||
<div th:if="${param.error}" class="alert alert-danger margin-bottom">
|
<div th:if="${param.error}" class="alert alert-danger margin-bottom">
|
||||||
Пользователь не найден или пароль указан не верно
|
Пользователь не найден или пароль указан не верно
|
||||||
</div>
|
|
||||||
<div th:if="${param.created}" class="alert alert-success margin-bottom">
|
|
||||||
Пользователь '<span th:text="${param.created}"></span>' успешно создан
|
|
||||||
</div>
|
|
||||||
<div th:if="${param.logout}" class="alert alert-success margin-bottom">
|
|
||||||
Выход успешно произведен
|
|
||||||
</div>
|
|
||||||
<form th:action="@{/login}" method="post" class="container-padding">
|
|
||||||
<div class="mb-3">
|
|
||||||
<input type="text" name="username" id="username" class="form-control“
|
|
||||||
placeholder="Логин" required="true" autofocus="true"/>
|
|
||||||
</div>
|
|
||||||
<div class="mb-3">
|
|
||||||
<input type="password" name="password" id="password" class="form-control“
|
|
||||||
placeholder="Пароль" required="true"/>
|
|
||||||
</div>
|
|
||||||
<button type="submit" class="btn btn-success button-fixed">Войти</button>
|
|
||||||
<a class="btn btn-primary button-fixed" href="/signup">Регистрация</a>
|
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div th:if="${param.logout}" class="alert alert-success margin-bottom">
|
||||||
|
Выход успешно произведен
|
||||||
|
</div>
|
||||||
|
<div th:if="${param.created}" class="alert alert-success margin-bottom">
|
||||||
|
Пользователь '<span th:text="${param.created}"></span>' успешно создан
|
||||||
|
</div>
|
||||||
|
<form th:action="@{/login}" method="post" class="container-padding">
|
||||||
|
<div class="mb-3">
|
||||||
|
<input type="text" name="username" id="username" class="form-control"
|
||||||
|
placeholder="Логин" required="true" autofocus="true"/>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<input type="password" name="password" id="password" class="form-control"
|
||||||
|
placeholder="Пароль" required="true"/>
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-success button-fixed">Войти</button>
|
||||||
|
<a class="btn btn-primary button-fixed" href="/signup">Регистрация</a>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
@ -49,34 +49,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- <div class="table-responsive">
|
|
||||||
<table class="table">
|
|
||||||
<tbody>
|
|
||||||
<tr th:each="nation, iterator: ${nations}">
|
|
||||||
<th scope="row" th:text="${iterator.index} + 1"/>
|
|
||||||
<td th:text="${nation.id}"/>
|
|
||||||
<td th:text="${nation.nation}" style="width: 60%"/>
|
|
||||||
<td style="width: 10%">
|
|
||||||
<div class="btn-group" role="group" aria-label="Basic example">
|
|
||||||
<a class="btn btn-warning button-fixed button-sm"
|
|
||||||
th:href="@{/nation/edit/{id}(id=${nation.id})}">
|
|
||||||
<i class="fa fa-pencil" aria-hidden="true"></i> Изменить
|
|
||||||
</a>
|
|
||||||
<button type="button" class="btn btn-danger button-fixed button-sm"
|
|
||||||
th:attr="onclick=|confirm('Удалить нацию?') && document.getElementById('remove-${nation.id}').click()|">
|
|
||||||
<i class="fa fa-trash" aria-hidden="true"></i> Удалить
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<form th:action="@{/nation/delete/{id}(id=${nation.id})}" method="post">
|
|
||||||
<button th:id="'remove-' + ${nation.id}" type="submit" style="display: none">
|
|
||||||
Удалить
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div> -->
|
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
<th:block layout:fragment="scripts">
|
<th:block layout:fragment="scripts">
|
||||||
|
@ -9,18 +9,26 @@
|
|||||||
<body>
|
<body>
|
||||||
<div class="container container-padding" layout:fragment="content">
|
<div class="container container-padding" layout:fragment="content">
|
||||||
<div th:if="${errors}" th:text="${errors}" class="margin-bottom alert alert-danger"></div>
|
<div th:if="${errors}" th:text="${errors}" class="margin-bottom alert alert-danger"></div>
|
||||||
<form action="#" th:action="@{/signup}" th:object="${userDto}" method="post">
|
<form action="#" th:action="@{/signup}" th:object="${clientDTO}" method="post">
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<input type="text" class="form-control" th:field="${clientDTO.login}“
|
<input type="text" class="form-control" th:field="${clientDTO.login}"
|
||||||
placeholder="Логин" required="true" autofocus="true" maxlength="64"/>
|
placeholder="Логин" required="true" autofocus="true" maxlength="64"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<input type="password" class="form-control" th:field="${clientDTO.password}“
|
<input type="text" class="form-control" th:field="${clientDTO.email}"
|
||||||
placeholder="Пароль" required="true" minlength="6" maxlength="64"/>
|
placeholder="Почта" required="true" autofocus="true" maxlength="64"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<input type="password" class="form-control" th:field="${clientDTO.passwordConfirm}“
|
<input type="text" class="form-control" th:field="${clientDTO.balance}"
|
||||||
placeholder="Пароль (подтверждение)" required="true" minlength="6" maxlength="64"/>
|
placeholder="Балланс" maxlength="64"/>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<input type="password" class="form-control" th:field="${clientDTO.password}"
|
||||||
|
placeholder="Пароль" required="true" minlength="6" maxlength="64"/>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<input type="password" class="form-control" th:field="${clientDTO.passwordConfirm}"
|
||||||
|
placeholder="Пароль (подтверждение)" required="true" minlength="6" maxlength="64"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<button type="submit" class="btn btn-success button-fixed">Создать</button>
|
<button type="submit" class="btn btn-success button-fixed">Создать</button>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user