Skip to content

Commit

Permalink
Merge pull request #1259 from mozzy11/develop
Browse files Browse the repository at this point in the history
exclude Global admin from Login Lab Unit
  • Loading branch information
mozzy11 authored Sep 10, 2024
2 parents 0ae8e1a + 64d4f19 commit af5521a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion frontend/src/components/security/SecureRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { confirmAlert } from "react-confirm-alert";
import "react-confirm-alert/src/react-confirm-alert.css"; // Import css
import { Loading, Modal } from "@carbon/react/";
import config from "../../config.json";
import { Roles } from "../utils/Utils";
import { FormattedMessage, useIntl } from "react-intl";

const idleTimeout = 1000 * 60 * 30; // milliseconds until idle warning will appear
Expand Down Expand Up @@ -37,7 +38,8 @@ function SecureRoute(props) {
console.info("Access Allowed");
if (
configurationProperties.REQUIRE_LAB_UNIT_AT_LOGIN === "true" &&
!userSessionDetails.loginLabUnit
!userSessionDetails.loginLabUnit &&
!userSessionDetails.roles.includes(Roles.GLOBAL_ADMIN)
) {
window.location.href = "/landing";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.openelisglobal.analysis.valueholder.Analysis;
import org.openelisglobal.common.constants.Constants;
import org.openelisglobal.common.services.DisplayListService;
import org.openelisglobal.common.services.DisplayListService.ListType;
import org.openelisglobal.common.util.ConfigurationProperties;
Expand Down Expand Up @@ -166,8 +167,10 @@ public List<IdValuePair> getUserTestSections(String systemUserId, String roleId)
Boolean requireLabUnitAtLogin = ConfigurationProperties.getInstance()
.getPropertyValue(Property.REQUIRE_LAB_UNIT_AT_LOGIN).equals("true");
UserSessionData usd = (UserSessionData) session.getAttribute("userSessionData");
String adminRoleId = roleService.getRoleByName(Constants.ROLE_GLOBAL_ADMIN).getId();
Boolean isadmin = userRoleService.getRoleIdsForUser(systemUserId).contains(adminRoleId);
TestSection logintestSection = null;
if (requireLabUnitAtLogin) {
if (requireLabUnitAtLogin && !isadmin) {
if (usd.getLoginLabUnit() != 0) {
logintestSection = testSectionService.getTestSectionById(String.valueOf(usd.getLoginLabUnit()));
if (logintestSection != null) {
Expand Down

0 comments on commit af5521a

Please sign in to comment.