При попытке войти появляется лог:
2025-01-19T23:46:34.220+01:00 WARN 388 --- [TrippiApp] [nio-8080-exec-4].w.s.m.s.DefaultHandlerExceptionResolver: решено [org.springframework.web.HttpRequestMethodNotSupportedException: метод запроса «POST» не поддерживается]
Доступен вход на страницу входа по умолчанию, поэтому я предполагаю, что с SecurityFilterChain что-то не так
Код: Выделить всё
@Configuration
@EnableWebSecurity
public class SecurityConfig {
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http.csrf(csrf -> csrf.disable()).authorizeHttpRequests(requests -> requests
.dispatcherTypeMatchers().permitAll()
.requestMatchers("/CSS/**").permitAll()
.requestMatchers("/login /register /search").hasAnyRole("USER", "ADMIN")
.anyRequest().authenticated()
)
.formLogin(login -> login
.loginPage("/login")
.loginProcessingUrl("/userAuth")
.defaultSuccessUrl("/register")
.failureForwardUrl("/login?error")
.permitAll())
.logout(logout -> logout.logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
.permitAll());
return http.build();
}
}
Код: Выделить всё
@Controller
public class AuthorisationController {
private UserService userService;
public AuthorisationController(UserService userService) {
this.userService = userService;
}
@GetMapping("/login")
public String login() {
return "login";
}
Код: Выделить всё
Register
Konto
Szukaj
Wiadomości
Logowanie
Rejestracja
Wyloguj
Użytkownik
Logowanie
Zły nick lub hasło!
Wylogowałeś się!
Nick:
Hasło:
Zaloguj
Подробнее здесь: https://stackoverflow.com/questions/793 ... t-to-login
Мобильная версия