Skip to content

Commit c6b102b

Browse files
committed
Handle deleted and disabled configurations more gracefully
1 parent 62510f7 commit c6b102b

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

core/src/org/labkey/core/login/LoginController.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1642,6 +1642,8 @@ protected URLHelper getUrl(SSOAuthenticationConfiguration<?> configuration, View
16421642
}
16431643
}
16441644

1645+
private static final String CONFIGURATION_ADVICE = ". Please Sign Out and Sign In again.";
1646+
16451647
@SuppressWarnings("unused") // Called from client code
16461648
@RequiresLogin
16471649
public static class GetAuthenticationConfigurationAction extends ReadOnlyApiAction<ReturnUrlForm>
@@ -1652,7 +1654,11 @@ public Object execute(ReturnUrlForm form, BindException errors)
16521654
PrimaryAuthenticationConfiguration<?> configuration = AuthenticationManager.getConfiguration(getViewContext().getSession());
16531655
if (configuration == null)
16541656
{
1655-
throw new NotFoundException("No configuration found");
1657+
throw new NotFoundException("Configuration was not found" + CONFIGURATION_ADVICE);
1658+
}
1659+
if (!configuration.isEnabled())
1660+
{
1661+
throw new NotFoundException("Configuration is no longer active" + CONFIGURATION_ADVICE);
16561662
}
16571663
JSONObject resp = new JSONObject();
16581664
resp.put("description", configuration.getDescription());

devtools/src/org/labkey/devtools/view/testReauth.jsp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,21 @@
3434
success: function(response) {
3535
const needReauth = <%=form.reauthToken() == null%>;
3636
const data = JSON.parse(response.responseText).data;
37-
document.getElementById("description").textContent = data.description;
37+
document.getElementById("description").textContent = data.description; // Setting textContent HTML encodes the value
3838
if (needReauth) {
3939
document.getElementById("link").href = data.reauthUrl;
4040
}
4141
},
42-
failure: function() {
43-
alert('Failed to retrieve configuration!');
44-
}
42+
failure: LABKEY.Utils.getCallbackWrapper(function(response) {
43+
document.getElementById("content").innerHTML = '<span>' + LABKEY.Utils.encodeHtml(response.exception) + '</span>';
44+
}, this, true)
4545
});
4646
});
4747
</script>
4848

49-
You authenticated with: <span id="description"></span><br/>
49+
<div id="content">
50+
51+
You authenticated with: <span id="description"></span><br/>
5052

5153
<%
5254
if (form.reauthToken() != null)
@@ -79,3 +81,5 @@ You need to re-authenticate.
7981
<%
8082
}
8183
%>
84+
85+
</div>

0 commit comments

Comments
 (0)