Skip to content

Commit

Permalink
Merge pull request #4200 from Rashmini/recovery-v2
Browse files Browse the repository at this point in the history
Update recovery portal to v2
  • Loading branch information
Rashmini authored Oct 18, 2023
2 parents 212e16b + 6957fe7 commit 327c73d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/quick-kangaroos-drive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@wso2is/identity-apps-core": patch
---

Update recovery portal for recovery v2 API
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.Map" %>
<%@ page import="org.wso2.carbon.identity.mgt.endpoint.util.client.api.PasswordRecoveryApiV1" %>
<%@ page import="org.wso2.carbon.identity.mgt.endpoint.util.client.model.passwordrecovery.v1.*" %>
<%@ page import="org.wso2.carbon.identity.mgt.endpoint.util.client.api.RecoveryApiV2" %>
<%@ page import="org.wso2.carbon.identity.mgt.endpoint.util.client.model.recovery.v2.*" %>
<%@ page import="org.wso2.carbon.identity.mgt.endpoint.util.client.api.UsernameRecoveryApi" %>
<%@ page import="org.wso2.carbon.identity.mgt.endpoint.util.client.model.*" %>
<%@ page import="org.wso2.carbon.identity.mgt.endpoint.util.IdentityManagementEndpointConstants" %>
Expand Down Expand Up @@ -93,13 +93,13 @@
RecoveryInitRequest recoveryInitRequest = new RecoveryInitRequest();
recoveryInitRequest.setClaims(claimDTOList);
PasswordRecoveryApiV1 passwordRecoveryApiV1 = new PasswordRecoveryApiV1();
RecoveryApiV2 recoveryApiV2 = new RecoveryApiV2();
try {
Map<String, String> requestHeaders = new HashedMap();
if (recaptchaResponse != null) {
requestHeaders.put("g-recaptcha-response", recaptchaResponse);
}
List<AccountRecoveryType> accountRecoveryTypes = passwordRecoveryApiV1.
List<AccountRecoveryType> accountRecoveryTypes = recoveryApiV2.
initiatePasswordRecovery(recoveryInitRequest, tenantDomain, requestHeaders);
if (accountRecoveryTypes == null) {
request.setAttribute("callback", callback);
Expand All @@ -108,7 +108,7 @@
response);
return;
}
IdentityManagementEndpointUtil.addReCaptchaHeaders(request, passwordRecoveryApiV1.getApiClient().getResponseHeaders());
IdentityManagementEndpointUtil.addReCaptchaHeaders(request, recoveryApiV2.getApiClient().getResponseHeaders());
for (AccountRecoveryType accountRecoveryType : accountRecoveryTypes) {
if (accountRecoveryType.getMode().equals("recoverWithNotifications")) {
isNotificationBasedRecoveryEnabled = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<%@ page import="org.wso2.carbon.identity.mgt.endpoint.util.IdentityManagementEndpointUtil" %>
<%@ page import="org.wso2.carbon.identity.mgt.endpoint.util.client.ApiException" %>
<%@ page import="org.wso2.carbon.identity.mgt.endpoint.util.client.api.UsernameRecoveryApi" %>
<%@ page import="org.wso2.carbon.identity.mgt.endpoint.util.client.api.PasswordRecoveryApiV1" %>
<%@ page import="org.wso2.carbon.identity.mgt.endpoint.util.client.api.RecoveryApiV2" %>
<%@ page import="org.wso2.carbon.identity.mgt.endpoint.util.client.model.Claim" %>
<%@ page import="org.wso2.carbon.identity.mgt.endpoint.util.client.model.UserClaim" %>
<%@ page import="org.wso2.carbon.user.core.util.UserCoreUtil" %>
Expand All @@ -35,7 +35,7 @@
<%@ page import="java.util.Map" %>
<%@ page import="org.wso2.carbon.identity.mgt.endpoint.util.client.model.Property" %>
<%@ page import="java.net.URLEncoder" %>
<%@ page import="org.wso2.carbon.identity.mgt.endpoint.util.client.model.passwordrecovery.v1.*" %>
<%@ page import="org.wso2.carbon.identity.mgt.endpoint.util.client.model.recovery.v2.*" %>
<%@ page import="org.wso2.carbon.identity.mgt.endpoint.util.client.PreferenceRetrievalClient" %>
<%@ page import="org.wso2.carbon.identity.mgt.endpoint.util.client.PreferenceRetrievalClientException" %>

Expand Down Expand Up @@ -165,14 +165,14 @@
String recoveryCode = request.getParameter("recoveryCode");
String notificationChannel = "";
PasswordRecoveryApiV1 passwordRecoveryApiV1 = new PasswordRecoveryApiV1();
RecoveryApiV2 recoveryApiV2 = new RecoveryApiV2();
if (recoveryOption.equals("SECURITY_QUESTIONS")) {
username = IdentityManagementEndpointUtil.getFullQualifiedUsername(username, tenantDomain, null);
request.setAttribute("callback", callback);
request.setAttribute("sessionDataKey", sessionDataKey);
request.setAttribute("username", username);
session.setAttribute("username", username);
IdentityManagementEndpointUtil.addReCaptchaHeaders(request, passwordRecoveryApiV1.
IdentityManagementEndpointUtil.addReCaptchaHeaders(request, recoveryApiV2.
getApiClient().getResponseHeaders());
request.getRequestDispatcher("challenge-question-request.jsp?username=" + username).forward(request,
response);
Expand All @@ -195,7 +195,7 @@
recoveryRequest.setRecoveryCode(recoveryCode);
try {
Map<String, String> requestHeaders = new HashedMap();
RecoveryResponse recoveryResponse = passwordRecoveryApiV1.recoverPassword(recoveryRequest,
RecoveryResponse recoveryResponse = recoveryApiV2.recoverPassword(recoveryRequest,
tenantDomain, requestHeaders);
notificationChannel = recoveryResponse.getNotificationChannel();
request.setAttribute("callback", callback);
Expand Down
2 changes: 1 addition & 1 deletion identity-apps-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@
<carbon.extension.identity.authenticator.version>3.0.0</carbon.extension.identity.authenticator.version>
<org.wso2.carbon.identity.association.account>5.1.5</org.wso2.carbon.identity.association.account>
<identity.extension.utils>1.0.8</identity.extension.utils>
<carbon.identity.framework.version>5.25.308</carbon.identity.framework.version>
<carbon.identity.framework.version>5.25.402</carbon.identity.framework.version>
<carbon.identity.framework.imp.pkg.version.range>[5.0.0, 7.0.0]</carbon.identity.framework.imp.pkg.version.range>
<identity.organization.management.core.service.version>1.0.0
</identity.organization.management.core.service.version>
Expand Down

0 comments on commit 327c73d

Please sign in to comment.