Source:
<code>private Response afterPostBrokerLoginFlowSuccess(AuthenticationSessionModel authSession, BrokeredIdentityContext context, boolean wasFirstBrokerLogin, ClientSessionCode<AuthenticationSessionModel> clientSessionCode) { String providerId = context.getIdpConfig().getAlias(); UserModel federatedUser = authSession.getAuthenticatedUser(); if (wasFirstBrokerLogin) { return finishBrokerAuthentication(context, federatedUser, authSession, providerId); } else { boolean firstBrokerLoginInProgress = (authSession.getAuthNote(AbstractIdpAuthenticator.BROKERED_CONTEXT_NOTE) != null); if (firstBrokerLoginInProgress) { logger.debugf("Reauthenticated with broker '%s' when linking user '%s' with other broker", context.getIdpConfig().getAlias(), federatedUser.getUsername()); try { <START> UserModel linkingUser = AbstractIdpAuthenticator.getExistingUser(session, realmModel, authSession); <END> if (!linkingUser.getId().equals(federatedUser.getId())) { return redirectToErrorPage(authSession, Response.Status.BAD_REQUEST, Messages.IDENTITY_PROVIDER_DIFFERENT_USER_MESSAGE, federatedUser.getUsername(), linkingUser.getUsername()); } } catch (AuthenticationFlowException e) { logger.debug("No existing user in authSession", e); } SerializedBrokeredIdentityContext serializedCtx = SerializedBrokeredIdentityContext.readFromAuthenticationSession(authSession, AbstractIdpAuthenticator.BROKERED_CONTEXT_NOTE); authSession.setAuthNote(AbstractIdpAuthenticator.FIRST_BROKER_LOGIN_SUCCESS, serializedCtx.getIdentityProviderId()); return afterFirstBrokerLogin(clientSessionCode); } else { return finishBrokerAuthentication(context, federatedUser, authSession, providerId); } } }</code><technical_language>Instead of this change, remove check for if (!linkingUser.getId().equals(federatedUser.getId())) entirely? this PR, is a user authenticated in username/password form in "AbstractIdpAuthenticator.getExistingUser" . I logic for broker re-authentication. This means IDENTITY_PROVIDER_DIFFERENT_USER_MESSAGE removed "Messages" class resource bundles. I similar change need done in ResetCredentialsActionTokenHandler</technical_language>

Target:
private Response afterPostBrokerLoginFlowSuccess(AuthenticationSessionModel authSession, BrokeredIdentityContext context, boolean wasFirstBrokerLogin, ClientSessionCode<AuthenticationSessionModel> clientSessionCode) { String providerId = context.getIdpConfig().getAlias(); UserModel federatedUser = authSession.getAuthenticatedUser(); if (wasFirstBrokerLogin) { return finishBrokerAuthentication(context, federatedUser, authSession, providerId); } else { boolean firstBrokerLoginInProgress = (authSession.getAuthNote(AbstractIdpAuthenticator.BROKERED_CONTEXT_NOTE) != null); if (firstBrokerLoginInProgress) { logger.debugf("Reauthenticated with broker '%s' when linking user '%s' with other broker", context.getIdpConfig().getAlias(), federatedUser.getUsername()); SerializedBrokeredIdentityContext serializedCtx = SerializedBrokeredIdentityContext.readFromAuthenticationSession(authSession, AbstractIdpAuthenticator.BROKERED_CONTEXT_NOTE); authSession.setAuthNote(AbstractIdpAuthenticator.FIRST_BROKER_LOGIN_SUCCESS, serializedCtx.getIdentityProviderId()); return afterFirstBrokerLogin(clientSessionCode); } else { return finishBrokerAuthentication(context, federatedUser, authSession, providerId); } } }