Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable current recovery service #766

Merged
merged 5 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ public enum ErrorMessages {
"User account recovery validation failed for user account: '%s'"),
ERROR_CODE_INVALID_RECOVERY_FLOW_ID("UAR-10015", "Invalid confirmation code : '%s'."),
ERROR_CODE_EXPIRED_RECOVERY_FLOW_ID("UAR-10016", "Expired confirmation code : '%s'."),
ERROR_CODE_API_DISABLED("UAR-10017", "Recovery API is disabled."),
ERROR_CODE_NO_RECOVERY_FLOW_DATA("UAR-10018", "No recovery flow data found for "
+ "recovery flow id : '%s'."),
ERROR_CODE_ERROR_STORING_RECOVERY_DATA("UAR-15001", "Error storing user recovery data"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.identity.application.common.model.User;
import org.wso2.carbon.identity.base.IdentityConstants;
import org.wso2.carbon.identity.core.util.IdentityTenantUtil;
import org.wso2.carbon.identity.core.util.IdentityUtil;
import org.wso2.carbon.identity.event.IdentityEventException;
Expand Down Expand Up @@ -189,6 +190,11 @@ public PasswordRecoverDTO notify(String recoveryCode, String channelId, String t
public PasswordResetCodeDTO confirm(String confirmationCode, String tenantDomain, Map<String, String> properties)
throws IdentityRecoveryException {

if (!Boolean.parseBoolean(IdentityUtil.getProperty(
IdentityConstants.Recovery.RECOVERY_V1_API_ENABLE))) {
throw Utils.handleClientException(
IdentityRecoveryConstants.ErrorMessages.ERROR_CODE_API_DISABLED, null);
}
validateTenantDomain(tenantDomain);
UserAccountRecoveryManager userAccountRecoveryManager = UserAccountRecoveryManager.getInstance();
// Get Recovery data.
Expand Down Expand Up @@ -290,6 +296,11 @@ public PasswordResetCodeDTO confirm(String otp, String confirmationCode, String
public SuccessfulPasswordResetDTO reset(String resetCode, char[] password, Map<String, String> properties)
throws IdentityRecoveryException {

if (!Boolean.parseBoolean(IdentityUtil.getProperty(
IdentityConstants.Recovery.RECOVERY_V1_API_ENABLE))) {
throw Utils.handleClientException(
IdentityRecoveryConstants.ErrorMessages.ERROR_CODE_API_DISABLED, null);
}
// Validate the password.
if (ArrayUtils.isEmpty(password)) {
throw Utils.handleClientException(
Expand Down
Loading