Olá pessoal,
Gostaria de saber como eu posso manter o campo do username do login preenchido após ocorrer de algum usuário errar o login ou a senha. Ele apenas limpe o campo de senha.
Meu código do Spring security :
@Configuration
@EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter{
@Autowired
private UserDetailsService users;
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/login").anonymous()
.anyRequest().authenticated()
.and()
.formLogin().loginPage("/login")
.defaultSuccessUrl("/")
.usernameParameter("username")
.passwordParameter("password")
.and()
.exceptionHandling().accessDeniedPage("/")
.and()
.logout()
.logoutRequestMatcher(new AntPathRequestMatcher("/logout"));
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(users)
.passwordEncoder(new BCryptPasswordEncoder());
}
@Override
public void configure(WebSecurity web) throws Exception {
web
.ignoring()
.antMatchers("/resources/**")
.antMatchers("/webjars/**");
}
}
Meu Controller:
@Controller
public class AuthController {
@RequestMapping("/login")
public ModelAndView login(){
return new ModelAndView("auth/login");
}
}
O HTML é o padrão para customização do login; Se for realmente pertinente eu posso postar eles para maiores dúvidas referente ao que há dentro do HTML.
Obrigada desde já.