rest-walkthrough-solution branch of LaunchCodeTraining/launchcartsecurely-hash-passwords via $ git checkout -b securely-hash-passwords//TODO commentsAdd the Spring Security dependency to build.gradle:
dependencies {
compile('org.springframework.security:spring-security-crypto')
//more dependencies will be listed above or below...
}
Create a static final instance of the encoder class, within User:
private static final BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
Use BCryptPasswordEncoder.encode in the User.java contructor:
public User(String username, String password) {
this.username = username;
this.pwHash = hashPassword(password);
}
private static String hashPassword(String password) {
return encoder.encode(password);
}
Update isMatchingPassword(String password):
public boolean isMatchingPassword(String password) {
return encoder.matches(password, this.pwHash);
}
bootRun and see if you can register (register a few users)