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

Bugfix/email security object absence #12

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
8 changes: 8 additions & 0 deletions dependencies-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -3056,6 +3056,14 @@
"type" : "jar",
"optional" : false,
"integrity" : "sha512:69vFpDGFVg9xxTjx/ClXNn6MBqRQesdAj+JSfEngno0dt3FhqkTBfmyt/T7DPTZI/iFvFqt1Mwbx9Oae6Y8lrg=="
}, {
"groupId" : "org.springframework.security",
"artifactId" : "spring-security-crypto",
"version" : "5.8.16",
"scope" : "compile",
"type" : "jar",
"optional" : false,
"integrity" : "sha512:uuIy7D74iKO0pCZJz+3aZLYGLhE0UyiEnvUdLlsp+V+ldIzgD93YLd0HxjfAwn9DaZNyKjoQbo1G/y0RTqFtAw=="
}, {
"groupId" : "org.springframework",
"artifactId" : "spring-aop",
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/org/oscarehr/managers/EmailComposeManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
Expand All @@ -22,6 +23,7 @@
import org.oscarehr.common.model.EmailAttachment;
import org.oscarehr.common.model.EmailConfig;
import org.oscarehr.common.model.EmailLog;
import org.oscarehr.common.model.SecObjectName;
import org.oscarehr.common.model.UserProperty;
import org.oscarehr.common.model.enumerator.DocumentType;
import org.oscarehr.documentManager.DocumentAttachmentManager;
Expand Down Expand Up @@ -231,6 +233,11 @@ public String createEmailPDFPassword(LoggedInInfo loggedInInfo, Integer demograp
return demographic.getYearOfBirth() + demographic.getMonthOfBirth() + demographic.getDateOfBirth() + demographic.getHin();
}

public boolean hasEmailPrivilege(LoggedInInfo loggedInInfo, String privilege) {
boolean hasEmailPrivilege = securityInfoManager.hasPrivilege(loggedInInfo, "_email", privilege, null);
return hasEmailPrivilege;
}

private boolean isValidEmail(String email) {
EmailValidator emailValidator = EmailValidator.getInstance();
return emailValidator.isValid(email);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public class SecurityInfoManagerImpl implements SecurityInfoManager {
@Autowired
private SecuserroleDao secUserRoleDao;


@Autowired
private SecobjprivilegeDao secobjprivilegeDao;

Expand Down
2 changes: 2 additions & 0 deletions src/main/webapp/admin/providerRole.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,9 @@ if(newCaseManagement) {
List programProvider = programProviderDao.getProgramProvidersByProvider(user);

if(programProvider == null || programProvider.isEmpty()) {
System.out.println("user: " + user);
ProviderData provider = providerDao.findByProviderNo(user);
if (provider == null) { System.out.println("\n------------------\n\n\n\n"); }
msg += String.format("</br><span style='color:red;'>WARNING: Provider %s requires a primary role assignment.</span>", provider.getFirstName() + " " + provider.getLastName());
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/webapp/casemgmt/ChartNotesAjax.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@
<%@page import="org.oscarehr.common.model.CasemgmtNoteLock"%>
<%@page import="org.oscarehr.common.model.EmailLog"%>
<%@page import="org.oscarehr.managers.EmailManager"%>
<%@page import="org.oscarehr.managers.EmailComposeManager"%>
<%@page import="org.oscarehr.managers.SecurityInfoManager"%>

<%
String roleName2$ = (String)session.getAttribute("userrole") + "," + (String) session.getAttribute("user");
Expand All @@ -88,6 +90,7 @@ Facility facility = loggedInInfo.getCurrentFacility();
ProfessionalSpecialistDao professionalSpecialistDao=(ProfessionalSpecialistDao)SpringUtils.getBean(ProfessionalSpecialistDao.class);

EmailManager emailManager = SpringUtils.getBean(EmailManager.class);
EmailComposeManager emailComposeManager = SpringUtils.getBean(EmailComposeManager.class);

String pId = (String)session.getAttribute("case_program_id");
Program program = null;
Expand Down Expand Up @@ -317,6 +320,7 @@ CasemgmtNoteLock casemgmtNoteLock = (CasemgmtNoteLock)session.getAttribute("case
} else if (note.isInvoice()) {
globalNoteId = "INV" + note.getNoteId();
} else if (note.isEmailNote()) {
if (!emailComposeManager.hasEmailPrivilege(loggedInInfo, SecurityInfoManager.READ)) { continue; }
EmailLog emailLog = emailManager.getEmailLogByCaseManagementNoteId(loggedInInfo, Long.valueOf(noteId));
if (emailLog == null) { continue; }
dispDocNo = String.valueOf(emailLog.getId());
Expand Down
6 changes: 6 additions & 0 deletions src/main/webapp/eform/efmformadd_data.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

<%@ page import="oscar.eform.data.*"%>
<%@ page import="org.oscarehr.managers.EmailComposeManager"%>
<%@ page import="org.oscarehr.managers.SecurityInfoManager"%>
<%@ page import="org.oscarehr.util.SpringUtils"%>
<%@ page import="org.oscarehr.util.LoggedInInfo"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
Expand Down Expand Up @@ -61,6 +62,11 @@
<%!
public void addHiddenEmailProperties(LoggedInInfo loggedInInfo, EForm thisEForm, String demographicNo) {
EmailComposeManager emailComposeManager = SpringUtils.getBean(EmailComposeManager.class);
if (!emailComposeManager.hasEmailPrivilege(loggedInInfo, SecurityInfoManager.WRITE)) {
thisEForm.addHiddenInputElement("hasEmailPrivilege", Boolean.FALSE.toString());
return;
}

Boolean hasValidRecipient = emailComposeManager.hasValidRecipient(loggedInInfo, Integer.parseInt(demographicNo));
String[] emailConsent = emailComposeManager.getEmailConsentStatus(loggedInInfo, Integer.parseInt(demographicNo));

Expand Down
6 changes: 6 additions & 0 deletions src/main/webapp/eform/efmshowform_data.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<%@ page import="org.oscarehr.common.model.enumerator.DocumentType"%>
<%@ page import="org.oscarehr.documentManager.DocumentAttachmentManager"%>
<%@ page import="org.oscarehr.managers.EmailComposeManager"%>
<%@ page import="org.oscarehr.managers.SecurityInfoManager"%>
<%@ page import="org.oscarehr.util.SpringUtils"%>
<%@ page import="oscar.util.StringUtils" %>
<%@ page import="java.util.List"%>
Expand All @@ -52,6 +53,11 @@

public void addHiddenEmailProperties(LoggedInInfo loggedInInfo, EForm eForm, String demographicNo) {
EmailComposeManager emailComposeManager = SpringUtils.getBean(EmailComposeManager.class);
if (!emailComposeManager.hasEmailPrivilege(loggedInInfo, SecurityInfoManager.WRITE)) {
eForm.addHiddenInputElement("hasEmailPrivilege", Boolean.FALSE.toString());
return;
}

Boolean hasValidRecipient = emailComposeManager.hasValidRecipient(loggedInInfo, Integer.parseInt(demographicNo));
String[] emailConsent = emailComposeManager.getEmailConsentStatus(loggedInInfo, Integer.parseInt(demographicNo));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,9 @@ function remoteSave() {

// After adding floating toolbar update number of attachments
jQuery('#remoteTotalAttachments').empty().append(jQuery('.delegateAttachment').length);

// Check email privilege and if not, hide the Email button.
handleEmailPrivilege();
}

if (this.status === 404)
Expand Down Expand Up @@ -838,4 +841,17 @@ function remoteSave() {
}).appendTo("form[method='POST']");
})
}
})
})

function handleEmailPrivilege() {
// Get the value of the element with ID 'hasEmailPrivilege'
const hasEmailPrivilege = document.getElementById('hasEmailPrivilege');

if (hasEmailPrivilege) {
const value = hasEmailPrivilege.value.toLowerCase();
if (value === 'false') {
// If 'hasEmailPrivilege' is false, hide the 'remoteEmailButton'
document.getElementById('remoteEmailButton').style.display = 'none';
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,13 @@
<span class="btn-label"><i class="glyphicon glyphicon-import"></i></span>
Add to Documents
</button>

<button type="button" class="btn btn-default" value="Email" name="EmailButton" title="${isEmailEnabled ? 'Email' : 'Consent or Sender Details Not Configured'}" id="remoteEmailButton"
${isEmailEnabled ? '' : 'disabled'} onclick="remoteEmail()">
<span class="btn-label"><i class="glyphicon glyphicon-envelope"></i></span>
Email
</button>

<button type="button" class="btn btn-default" value="Attach" name="AttachButton" title="Add Attachment" id="remoteAttachButton" data-poload="">
<span class="btn-label"><i class="glyphicon glyphicon-plus"></i></span>
Attach <span class="badge" id="remoteTotalAttachments">0</span>
Expand Down