|
94 | 94 | import static org.wso2.carbon.identity.application.authenticator.basicauth.BasicAuthenticatorConstants.ACCOUNT_IS_LOCKED; |
95 | 95 | import static org.wso2.carbon.identity.application.authenticator.basicauth.BasicAuthenticatorConstants.ACCOUNT_LOCKED_REASON; |
96 | 96 | import static org.wso2.carbon.identity.application.authenticator.basicauth.BasicAuthenticatorConstants.ACCOUNT_PENDING_APPROVAL; |
| 97 | +import static org.wso2.carbon.identity.application.authenticator.basicauth.BasicAuthenticatorConstants.ASK_PASSWORD_VIA_OTP; |
97 | 98 | import static org.wso2.carbon.identity.application.authenticator.basicauth.BasicAuthenticatorConstants.AUTHENTICATOR_BASIC; |
98 | 99 | import static org.wso2.carbon.identity.application.authenticator.basicauth.BasicAuthenticatorConstants.AUTHENTICATOR_MESSAGE; |
99 | 100 | import static org.wso2.carbon.identity.application.authenticator.basicauth.BasicAuthenticatorConstants.DISPLAY_PASSWORD; |
@@ -448,6 +449,33 @@ protected void initiateAuthenticationRequest(HttpServletRequest request, |
448 | 449 | URLEncoder.encode(reason, BasicAuthenticatorConstants.UTF_8); |
449 | 450 | setAuthenticatorErrorMessage(getErrorMessage(errorCode, FORCED_PASSWORD_RESET_VIA_OTP), |
450 | 451 | context); |
| 452 | + } else if (errorCode.equals(IdentityCoreConstants.ASK_PASSWORD_SET_PASSWORD_VIA_OTP_ERROR_CODE)) { |
| 453 | + String username = request.getParameter(USER_NAME); |
| 454 | + String tenantDomain = getTenantDomainFromUserName(context, username); |
| 455 | + |
| 456 | + // Setting callback so that the user is prompted to login after setting password. |
| 457 | + String callback; |
| 458 | + try { |
| 459 | + callback = ServiceURLBuilder.create().addPath(loginPage).build().getAbsolutePublicURL(); |
| 460 | + } catch (URLBuilderException e) { |
| 461 | + throw new IdentityRuntimeException( |
| 462 | + "Error while building callback url for context: " + loginPage, e); |
| 463 | + } |
| 464 | + callback = callback + ("?" + queryParams) |
| 465 | + + BasicAuthenticatorConstants.AUTHENTICATORS + getName() + ":" + |
| 466 | + BasicAuthenticatorConstants.LOCAL; |
| 467 | + String reason = RecoveryScenarios.ASK_PASSWORD_VIA_EMAIL_OTP.name(); |
| 468 | + |
| 469 | + redirectURL = recoveryPage + CONFIRM_RECOVERY_DO + |
| 470 | + BasicAuthenticatorConstants.USER_NAME_PARAM + URLEncoder.encode(username, |
| 471 | + BasicAuthenticatorConstants.UTF_8) + BasicAuthenticatorConstants.TENANT_DOMAIN_PARAM + |
| 472 | + URLEncoder.encode(tenantDomain, BasicAuthenticatorConstants.UTF_8) + |
| 473 | + BasicAuthenticatorConstants.CONFIRMATION_PARAM + URLEncoder.encode(password, |
| 474 | + BasicAuthenticatorConstants.UTF_8) + BasicAuthenticatorConstants.CALLBACK_PARAM + |
| 475 | + URLEncoder.encode(callback, BasicAuthenticatorConstants.UTF_8) + |
| 476 | + BasicAuthenticatorConstants.REASON_PARAM + |
| 477 | + URLEncoder.encode(reason, BasicAuthenticatorConstants.UTF_8); |
| 478 | + setAuthenticatorErrorMessage(getErrorMessage(errorCode, ASK_PASSWORD_VIA_OTP), context); |
451 | 479 | } else if (errorCode.equals( |
452 | 480 | IdentityCoreConstants.USER_ACCOUNT_PENDING_APPROVAL_ERROR_CODE)) { |
453 | 481 | retryParam = BasicAuthenticatorConstants.AUTH_FAILURE_PARAM + "true" + |
|
0 commit comments