Skip to content

Commit

Permalink
Re-fix missing data in "focus identification" auth
Browse files Browse the repository at this point in the history
Improves the message emitted when no username (or other required piece
of information) is entered in "focus identification" module:
Instead of "please try later" we now provide "Invalid username and/or
password". It is still not 100% OK, but certainly better.

Related to MID-8726.
  • Loading branch information
mederly committed Apr 4, 2023
1 parent 3b1f6a6 commit 5d6b737
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationServiceException;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
Expand Down Expand Up @@ -65,9 +66,10 @@ protected Authentication internalAuthentication(Authentication authentication, L
if (authentication instanceof FocusVerificationToken) {
Map<ItemPath, String> attrValuesMap = (Map<ItemPath, String>) authentication.getDetails();
if (attrValuesMap == null || attrValuesMap.isEmpty()) {
// E.g. no user name provided when resetting the password (hence DEBUG, not ERROR)
// E.g. no user name or other required property provided when resetting the password.
// Hence DEBUG, not ERROR, and BadCredentialsException, not AuthenticationServiceException.
LOGGER.debug("No details provided: {}", authentication);
throw new AuthenticationServiceException("web.security.provider.unavailable"); // TODO better message key!
throw new BadCredentialsException(AuthUtil.generateBadCredentialsMessageKey(authentication));
}
ModuleAuthentication moduleAuthentication = AuthUtil.getProcessingModule();
List<ModuleItemConfigurationType> itemsConfig = null;
Expand Down

0 comments on commit 5d6b737

Please sign in to comment.