Include UsernameNotFoundException in BadCredentialsException

Closes gh-16496

Signed-off-by: dae won <eodnjs01477@gmail.com>
This commit is contained in:
dae won 2025-05-30 12:13:39 +09:00 committed by Josh Cummings
parent d52e0b6a05
commit 9654e51bd4

View File

@ -137,11 +137,12 @@ public abstract class AbstractUserDetailsAuthenticationProvider
}
catch (UsernameNotFoundException ex) {
this.logger.debug(LogMessage.format("Failed to find user '%s'", username));
String message = this.messages.getMessage("AbstractUserDetailsAuthenticationProvider.badCredentials",
"Bad credentials");
if (!this.hideUserNotFoundExceptions) {
throw ex;
}
throw new BadCredentialsException(this.messages
.getMessage("AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials"));
throw new BadCredentialsException(message, ex);
}
Assert.notNull(user, "retrieveUser returned null - a violation of the interface contract");
}