Skip to content

Commit

Permalink
Add primary domain to username if realm is passed as primary.
Browse files Browse the repository at this point in the history
  • Loading branch information
RushanNanayakkara committed Feb 1, 2024
1 parent 6e10a48 commit 21775e7
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.wso2.carbon.identity.recovery.internal.IdentityRecoveryServiceDataHolder;
import org.wso2.carbon.identity.recovery.password.NotificationPasswordRecoveryManager;
import org.wso2.carbon.identity.recovery.util.Utils;
import org.wso2.carbon.user.core.UserCoreConstants;
import org.wso2.carbon.user.core.util.UserCoreUtil;

import javax.ws.rs.core.Response;
Expand Down Expand Up @@ -53,7 +54,14 @@ public Response recoverPasswordPost(RecoveryInitiatingRequestDTO recoveryInitiat
if (IdentityRecoveryServiceDataHolder.getInstance().getMultiAttributeLoginService()
.isEnabled(user.getTenantDomain())) {
if (StringUtils.isNotBlank(user.getRealm())) {
String userDomainQualifiedUsername = UserCoreUtil.addDomainToName(user.getUsername(), user.getRealm());
String userDomainQualifiedUsername = UserCoreUtil.addDomainToName(user.getUsername(),
user.getRealm());
// the PRIMARY domain is not appended by UserCoreUtil.addDomainToName() method. Adding it here.
// This is done to avoid user being resolved when PRIMARY is wrongly passed as the user's realm.
if(!userDomainQualifiedUsername.contains(UserCoreConstants.DOMAIN_SEPARATOR)) {
userDomainQualifiedUsername = UserCoreConstants.PRIMARY_DEFAULT_DOMAIN_NAME +
UserCoreConstants.DOMAIN_SEPARATOR + userDomainQualifiedUsername;
}
user.setUsername(userDomainQualifiedUsername);
}
ResolvedUserResult resolvedUserResult =
Expand Down

0 comments on commit 21775e7

Please sign in to comment.