Fixed exception while logging in with unknown user

This commit is contained in:
Nanne Baars
2017-03-23 21:46:21 +01:00
parent 5156b05aac
commit 9833637abf
2 changed files with 30 additions and 1 deletions

View File

@ -19,7 +19,11 @@ public class UserService implements UserDetailsService {
@Override
public WebGoatUser loadUserByUsername(String username) throws UsernameNotFoundException {
WebGoatUser webGoatUser = userRepository.findByUsername(username);
webGoatUser.createUser();
if (webGoatUser == null) {
throw new UsernameNotFoundException("User not found");
} else {
webGoatUser.createUser();
}
return webGoatUser;
}