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

Add jsp improvements #13502

Merged
merged 1 commit into from
Jul 16, 2024
Merged
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
31 changes: 27 additions & 4 deletions modules/distribution/product/src/main/extensions/error.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
<%@ page isErrorPage="true" %>
<%@ page import="org.owasp.encoder.Encode" %>
<%@ page import="org.apache.commons.lang.StringUtils" %>
<%@ page import="org.wso2.carbon.identity.event.IdentityEventException" %>
<%@ page import="org.wso2.carbon.identity.mgt.endpoint.util.IdentityManagementEndpointUtil" %>
<%@ page import="org.wso2.carbon.identity.recovery.IdentityRecoveryConstants" %>
<%@ page import="org.wso2.carbon.identity.recovery.util.Utils" %>
<%@ page import="org.owasp.encoder.Encode" %>
<%@ page import="java.io.File" %>
<%@ page import="java.net.URISyntaxException" %>
Expand All @@ -32,8 +34,27 @@
<%
String errorMsg = IdentityManagementEndpointUtil.getStringValue(request.getAttribute("errorMsg"));
String errorCode = IdentityManagementEndpointUtil.getStringValue(request.getAttribute("errorCode"));
String invalidConfirmationErrorCode = IdentityRecoveryConstants.ErrorMessages.ERROR_CODE_INVALID_CODE.getCode();
String callback = request.getParameter("callback");
boolean isValidCallback = true;

if (invalidConfirmationErrorCode.equals(errorCode)) {
String tenantDomain = StringUtils.EMPTY;
if (StringUtils.isNotBlank(request.getParameter("tenantdomain"))){
tenantDomain = request.getParameter("tenantdomain").trim();
} else if (StringUtils.isNotBlank(request.getParameter("tenantDomain"))){
tenantDomain = request.getParameter("tenantDomain").trim();
}
try {
if (StringUtils.isNotBlank(callback) && !Utils.validateCallbackURL
(callback, tenantDomain, IdentityRecoveryConstants.ConnectorConfig.RECOVERY_CALLBACK_REGEX)) {
isValidCallback = false;
}
} catch (IdentityEventException e) {
isValidCallback = false;
}
}

try {
IdentityManagementEndpointUtil.getURLEncodedCallback(callback);
} catch (URISyntaxException e) {
Expand Down Expand Up @@ -92,13 +113,11 @@
%>
</div>

<% if (isValidCallback) { %>
<div id="action-buttons" class="buttons">
<a href="javascript:goBack()" class="ui button primary button">
<a id = "go-back-button" href="javascript:goBack()" class="ui button primary button">
<%=IdentityManagementEndpointUtil.i18n(recoveryResourceBundle, "Go back")%>
</a>
</div>
<% } %>
</div>
</div>
</layout:component>
Expand Down Expand Up @@ -131,13 +150,17 @@
if ("<%=StringUtils.isEmpty(callback)%>" === "true") {
$("#action-buttons").hide();
}
if ("<%=isValidCallback%>" === "false") {
$("#go-back-button").addClass("disabled");
$("#action-buttons").attr("title", "Request has an invalid callback URL.");
}
});

<% if (isValidCallback) { %>
function goBack() {

var errorCodeFromParams = "<%=errorCode%>";
var invalidConfirmationErrorCode = "<%=IdentityRecoveryConstants.ErrorMessages.ERROR_CODE_INVALID_CODE.getCode()%>";
var invalidConfirmationErrorCode = "<%=invalidConfirmationErrorCode%>";

// Check if the error is related to the confirmation code being invalid.
// If so, navigate the users to the URL defined in `callback` URL param.
Expand Down
Loading