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 final GameClientService clientService;
|
||||
|
||||
@Autowired
|
||||
private UserDetailsService userDetailsService;
|
||||
|
||||
public SecurityConfiguration(GameClientService clientService) {
|
||||
this.clientService = clientService;
|
||||
createAdminOnStartup();
|
||||
|
@ -16,7 +16,7 @@ public class UserSignupDto {
|
||||
private String email;
|
||||
|
||||
@NotBlank
|
||||
private Integer balance;
|
||||
private String balance;
|
||||
|
||||
@NotBlank
|
||||
@Size(min = 6, max = 64)
|
||||
@ -38,7 +38,7 @@ public class UserSignupDto {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public void setBalance(Integer balance) {
|
||||
public void setBalance(String balance) {
|
||||
this.balance = balance;
|
||||
}
|
||||
|
||||
@ -58,7 +58,7 @@ public class UserSignupDto {
|
||||
return email;
|
||||
}
|
||||
|
||||
public Integer getBalance() {
|
||||
public String getBalance() {
|
||||
return balance;
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import premium_store.service.TankService;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping(WebConfiguration.REST_API + "/client")
|
||||
public class GameClientController {
|
||||
private final GameClientService gameClientService;
|
||||
|
@ -2,9 +2,6 @@ package premium_store.controller.controller;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
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.ui.Model;
|
||||
import org.springframework.validation.BindingResult;
|
||||
@ -15,31 +12,29 @@ import premium_store.service.GameClientService;
|
||||
import premium_store.service.TankService;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.ValidationException;
|
||||
import java.security.Principal;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/clients")
|
||||
public class ClientMvcController {
|
||||
@RequestMapping("/client")
|
||||
public class GameClientMvcController {
|
||||
private final GameClientService gameClientService;
|
||||
private final TankService tankService;
|
||||
|
||||
public ClientMvcController(GameClientService gameClientService, TankService tankService){
|
||||
public GameClientMvcController(GameClientService gameClientService, TankService tankService){
|
||||
this.gameClientService = gameClientService;
|
||||
this.tankService = tankService;
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@GetMapping({"/showUpdate"})
|
||||
public String showUpdateUserForm(Principal principal, Model model) {
|
||||
ClientDTO clientDTO = new ClientDTO(gameClientService.findByLogin(principal.getName()));
|
||||
model.addAttribute("clientDTO", clientDTO);
|
||||
return "client-edit";
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@GetMapping({"/getClients"})
|
||||
@Secured({UserRole.AsString.ADMIN})
|
||||
public String getClients(@RequestParam(defaultValue = "1") int page,
|
||||
@RequestParam(defaultValue = "5") int size,
|
||||
@ -62,7 +57,6 @@ public class ClientMvcController {
|
||||
}
|
||||
|
||||
@GetMapping(value = {"/edit", "/edit/{id}"})
|
||||
@PostMapping
|
||||
public String editClient(@ModelAttribute @Valid ClientDTO userDto,
|
||||
BindingResult bindingResult,
|
||||
Model model) {
|
@ -1,14 +1,10 @@
|
||||
package premium_store.controller.controller;
|
||||
|
||||
import net.bytebuddy.implementation.bind.MethodDelegationBinder;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import premium_store.controller.DTO.FullNationDTO;
|
||||
import premium_store.controller.DTO.LevelDTO;
|
||||
import premium_store.controller.DTO.SimpleNationDTO;
|
||||
import premium_store.service.NationService;
|
||||
import premium_store.service.TankLevelService;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
@ -41,12 +41,11 @@ public class UserSignupMvcController {
|
||||
return "signup";
|
||||
}
|
||||
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();
|
||||
} catch (ValidationException e) {
|
||||
model.addAttribute("errors", e.getMessage());
|
||||
return "signup";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,7 +24,7 @@
|
||||
Список существующих клиентов:
|
||||
</h1>
|
||||
</div>
|
||||
<div th:each="client, iterator: ${clients}">
|
||||
<div th:each="client, iterator: ${users}">
|
||||
<div class="client-card">
|
||||
<p class="client-attribute" th:text="'Номер: ' + ${client.id}"/>
|
||||
<p class="client-attribute" th:text="'Никнейм: ' + ${client.nickName}"/>
|
||||
@ -49,6 +49,14 @@
|
||||
</form>
|
||||
</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>
|
||||
</body>
|
||||
|
@ -2,7 +2,7 @@
|
||||
<html lang="ru"
|
||||
xmlns:th="http://www.thymeleaf.org"
|
||||
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>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Премиум магазин</title>
|
||||
@ -37,7 +37,7 @@
|
||||
th:classappend="${#strings.equals(activeLink, '/nation')} ? 'active' : ''">Обзор наций
|
||||
</a>
|
||||
<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 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>)
|
||||
|
@ -26,7 +26,7 @@
|
||||
</div>
|
||||
<div th:each="level, iterator: ${levels}">
|
||||
<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}"/>
|
||||
<div class='level-button-group'>
|
||||
<form th:action="@{/level/edit/{id}(id=${level.id})}" method="get">
|
||||
|
@ -1,33 +1,34 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"
|
||||
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>
|
||||
<script type="text/javascript" src="/webjars/jquery/3.6.0/jquery.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container" layout:fragment="content">
|
||||
<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 class="container" layout:fragment="content">
|
||||
<div th:if="${param.error}" class="alert alert-danger margin-bottom">
|
||||
Пользователь не найден или пароль указан не верно
|
||||
</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>
|
||||
</html>
|
@ -49,34 +49,6 @@
|
||||
</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>
|
||||
</body>
|
||||
<th:block layout:fragment="scripts">
|
||||
|
@ -9,18 +9,26 @@
|
||||
<body>
|
||||
<div class="container container-padding" layout:fragment="content">
|
||||
<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">
|
||||
<input type="text" class="form-control" th:field="${clientDTO.login}“
|
||||
placeholder="Логин" required="true" autofocus="true" maxlength="64"/>
|
||||
<input type="text" class="form-control" th:field="${clientDTO.login}"
|
||||
placeholder="Логин" required="true" autofocus="true" maxlength="64"/>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<input type="password" class="form-control" th:field="${clientDTO.password}“
|
||||
placeholder="Пароль" required="true" minlength="6" maxlength="64"/>
|
||||
<input type="text" class="form-control" th:field="${clientDTO.email}"
|
||||
placeholder="Почта" required="true" autofocus="true" maxlength="64"/>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<input type="password" class="form-control" th:field="${clientDTO.passwordConfirm}“
|
||||
placeholder="Пароль (подтверждение)" required="true" minlength="6" maxlength="64"/>
|
||||
<input type="text" class="form-control" th:field="${clientDTO.balance}"
|
||||
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 class="mb-3">
|
||||
<button type="submit" class="btn btn-success button-fixed">Создать</button>
|
||||
|
Loading…
x
Reference in New Issue
Block a user