Skip to content

Commit 4297f2a

Browse files
committed
Include UsernameNotFoundException in BadCredentialsException
Closes gh-16496 Signed-off-by: dae won <[email protected]>
1 parent fd4f06a commit 4297f2a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

core/src/main/java/org/springframework/security/authentication/dao/AbstractUserDetailsAuthenticationProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,11 @@ public Authentication authenticate(Authentication authentication) throws Authent
137137
}
138138
catch (UsernameNotFoundException ex) {
139139
this.logger.debug(LogMessage.format("Failed to find user '%s'", username));
140+
String message = this.messages.getMessage("AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials");
140141
if (!this.hideUserNotFoundExceptions) {
141142
throw ex;
142143
}
143-
throw new BadCredentialsException(this.messages
144-
.getMessage("AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials"));
144+
throw new BadCredentialsException(message, ex);
145145
}
146146
Assert.notNull(user, "retrieveUser returned null - a violation of the interface contract");
147147
}

0 commit comments

Comments
 (0)