Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMatt Malone
11,437 PointsEncrypted password not working
In SecurityConfig.java, I wrote in the following code:
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userService).passwordEncoder(passwordEncoder());
}
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder(10);
}
In import.sql, I changed 'password' to the 60-char BCrypt hash.
Now when I try to enter my username and password in the browser, I get "Incorrect username and/or password. Please try again."
Do you know what I've done wrong here? Thanks.
1 Answer
angel juarez
15,886 PointsI had the same issue, I used the encode method from the BycriptPasswordEncoder class to generate the password instead of using the one from the web site, and it worked for me. Here's the code: String password = "password"; BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); String hashedPassword = passwordEncoder.encode(password);
System.out.println(hashedPassword);
I copied and pasted it from to the console to the import.sql file