Skip to content

Commit

Permalink
Move realm name availability check before user search and adding blan…
Browse files Browse the repository at this point in the history
…k check.
  • Loading branch information
RushanNanayakkara committed Jan 31, 2024
1 parent 2087dc9 commit 6e10a48
Showing 1 changed file with 6 additions and 5 deletions.
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.util.UserCoreUtil;

import javax.ws.rs.core.Response;

Expand Down Expand Up @@ -51,18 +52,18 @@ public Response recoverPasswordPost(RecoveryInitiatingRequestDTO recoveryInitiat
// If multi attribute login is enabled, resolve the user before sending recovery notification sending.
if (IdentityRecoveryServiceDataHolder.getInstance().getMultiAttributeLoginService()
.isEnabled(user.getTenantDomain())) {
if (StringUtils.isNotBlank(user.getRealm())) {
String userDomainQualifiedUsername = UserCoreUtil.addDomainToName(user.getUsername(), user.getRealm());
user.setUsername(userDomainQualifiedUsername);
}
ResolvedUserResult resolvedUserResult =
IdentityRecoveryServiceDataHolder.getInstance().getMultiAttributeLoginService()
.resolveUser(user.getUsername(), user.getTenantDomain());
if (resolvedUserResult != null && ResolvedUserResult.UserResolvedStatus.SUCCESS.
equals(resolvedUserResult.getResolvedStatus())) {
User resolvedUser = new User();
resolvedUser.setUserName(resolvedUserResult.getUser().getUsername());
if (StringUtils.isBlank(user.getRealm())) {
resolvedUser.setUserStoreDomain(resolvedUserResult.getUser().getUserStoreDomain());
} else {
resolvedUser.setUserStoreDomain(user.getRealm());
}
resolvedUser.setUserStoreDomain(resolvedUserResult.getUser().getUserStoreDomain());
resolvedUser.setTenantDomain(resolvedUserResult.getUser().getTenantDomain());
notificationResponseBean =
notificationPasswordRecoveryManager.sendRecoveryNotification(resolvedUser, type, notify,
Expand Down

0 comments on commit 6e10a48

Please sign in to comment.