Сохранение перед перезагрузкой.
This commit is contained in:
parent
68a0bd7c14
commit
65800b9a6f
@ -33,7 +33,8 @@ dependencies {
|
|||||||
implementation group: 'org.springdoc', name: 'springdoc-openapi-ui', version: '1.6.5'
|
implementation group: 'org.springdoc', name: 'springdoc-openapi-ui', version: '1.6.5'
|
||||||
|
|
||||||
implementation 'org.springframework.boot:spring-boot-starter-security'
|
implementation 'org.springframework.boot:spring-boot-starter-security'
|
||||||
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6'
|
//implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6'
|
||||||
|
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6:3.1.1.RELEASE'
|
||||||
|
|
||||||
implementation 'org.hibernate.validator:hibernate-validator'
|
implementation 'org.hibernate.validator:hibernate-validator'
|
||||||
implementation 'org.springdoc:springdoc-openapi-ui:1.6.5'
|
implementation 'org.springdoc:springdoc-openapi-ui:1.6.5'
|
||||||
|
@ -7,6 +7,7 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
import org.springframework.http.HttpMethod;
|
import org.springframework.http.HttpMethod;
|
||||||
import org.springframework.security.authentication.AuthenticationManager;
|
import org.springframework.security.authentication.AuthenticationManager;
|
||||||
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
||||||
|
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
||||||
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
|
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
|
||||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||||
@ -36,7 +37,7 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
|
|||||||
final String admin = "admin";
|
final String admin = "admin";
|
||||||
if (clientService.findByLogin(admin) == null) {
|
if (clientService.findByLogin(admin) == null) {
|
||||||
log.info("Admin user successfully created");
|
log.info("Admin user successfully created");
|
||||||
clientService.addClient(admin, "adminemail@gmail.com", admin, admin, UserRole.ADMIN);
|
clientService.addClient(admin, "adminemail@gmail.com", admin, 0, admin, UserRole.ADMIN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,15 +47,15 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
|
|||||||
.cors().and()
|
.cors().and()
|
||||||
.csrf().disable()
|
.csrf().disable()
|
||||||
.authorizeHttpRequests()
|
.authorizeHttpRequests()
|
||||||
.requestMatchers(UserSignupMvcController.SIGNUP_URL).permitAll()
|
.antMatchers(UserSignupMvcController.SIGNUP_URL).permitAll()
|
||||||
.requestMatchers(HttpMethod.GET, LOGIN_URL).permitAll()
|
.antMatchers(HttpMethod.GET, LOGIN_URL).permitAll()
|
||||||
.anyRequest().authenticated()
|
.anyRequest().authenticated()
|
||||||
.and()
|
.and()
|
||||||
.formLogin()
|
.formLogin()
|
||||||
.loginPage(LOGIN_URL).permitAll()
|
.loginPage(LOGIN_URL).permitAll()
|
||||||
.and()
|
.and()
|
||||||
.logout().permitAll();
|
.logout().permitAll();
|
||||||
return http.build();
|
return http.userDetailsService(clientService).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ -65,12 +66,12 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
|
|||||||
return authenticationManagerBuilder.build();
|
return authenticationManagerBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
/*@Bean
|
||||||
public WebSecurityCustomizer webSecurityCustomizer() {
|
public WebSecurityCustomizer webSecurityCustomizer() {
|
||||||
return (web) -> web.ignoring()
|
return (web) -> web.ignoring()
|
||||||
.requestMatchers("/css/**")
|
.requestMatchers("/css/**")
|
||||||
.requestMatchers("/js/**")
|
.requestMatchers("/js/**")
|
||||||
.requestMatchers("/templates/**")
|
.requestMatchers("/templates/**")
|
||||||
.requestMatchers("/webjars/**");
|
.requestMatchers("/webjars/**");
|
||||||
}
|
}*/
|
||||||
}
|
}
|
@ -1,7 +1,13 @@
|
|||||||
package premium_store.configuration;
|
package premium_store.configuration;
|
||||||
|
|
||||||
|
import org.springframework.boot.web.server.ErrorPage;
|
||||||
|
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
|
||||||
|
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.ViewControllerRegistration;
|
||||||
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ public class ClientMvcController {
|
|||||||
|
|
||||||
if (bindingResult.hasErrors()) {
|
if (bindingResult.hasErrors()) {
|
||||||
model.addAttribute("errors", bindingResult.getAllErrors());
|
model.addAttribute("errors", bindingResult.getAllErrors());
|
||||||
return "user";
|
return "client-edit";
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -28,7 +28,7 @@ public class UserSignupMvcController {
|
|||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public String showSignupForm(Model model) {
|
public String showSignupForm(Model model) {
|
||||||
model.addAttribute("userDto", new UserSignupDto());
|
model.addAttribute("clientDTO", new UserSignupDto());
|
||||||
|
|
||||||
return "signup";
|
return "signup";
|
||||||
}
|
}
|
||||||
@ -41,8 +41,8 @@ public class UserSignupMvcController {
|
|||||||
return "signup";
|
return "signup";
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
final GameClient user = 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(), userSignupDto.getBalance(), userSignupDto.getPasswordConfirm(), UserRole.USER);
|
||||||
return "redirect:/login?created=" + user.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";
|
||||||
|
@ -13,12 +13,20 @@
|
|||||||
</div>
|
</div>
|
||||||
<form action="#" th:action="@{/client/{id}(id=${id})}" th:object="${supportClientDTO}" method="post">
|
<form action="#" th:action="@{/client/{id}(id=${id})}" th:object="${supportClientDTO}" method="post">
|
||||||
<div class="myModalContent">
|
<div class="myModalContent">
|
||||||
<label for="name" class="form-label">Никнейм: </label>
|
<label for="name" class="form-label">Логин: </label>
|
||||||
<input
|
<input
|
||||||
type='text'
|
type='text'
|
||||||
class="add-nation-input form-control"
|
class="add-nation-input form-control"
|
||||||
id="name"
|
id="name"
|
||||||
th:field="${supportClientDTO.nickName}"
|
th:field="${supportClientDTO.login}"
|
||||||
|
required="true"
|
||||||
|
/>
|
||||||
|
<label for="password" class="form-label">Пароль: </label>
|
||||||
|
<input
|
||||||
|
type='text'
|
||||||
|
class="add-nation-input form-control"
|
||||||
|
id="password"
|
||||||
|
th:field="${supportClientDTO.password}"
|
||||||
required="true"
|
required="true"
|
||||||
/>
|
/>
|
||||||
<label for="email" class="form-label">Почта: </label>
|
<label for="email" class="form-label">Почта: </label>
|
||||||
@ -54,7 +62,7 @@
|
|||||||
<button
|
<button
|
||||||
class="modalButton"
|
class="modalButton"
|
||||||
type="submit"
|
type="submit"
|
||||||
th:href="@{/client}"
|
th:href="@{/clients}"
|
||||||
>
|
>
|
||||||
Назад
|
Назад
|
||||||
</button>
|
</button>
|
||||||
|
@ -11,15 +11,15 @@
|
|||||||
<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="${userDto}" method="post">
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<input type="text" class="form-control" th:field="${userDto.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="${userDto.password}“
|
<input type="password" class="form-control" th:field="${clientDTO.password}“
|
||||||
placeholder="Пароль" required="true" minlength="6" maxlength="64"/>
|
placeholder="Пароль" required="true" minlength="6" maxlength="64"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<input type="password" class="form-control" th:field="${userDto.passwordConfirm}“
|
<input type="password" class="form-control" th:field="${clientDTO.passwordConfirm}“
|
||||||
placeholder="Пароль (подтверждение)" required="true" minlength="6" maxlength="64"/>
|
placeholder="Пароль (подтверждение)" required="true" minlength="6" maxlength="64"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user