susom / redcap-em-shibboleth-esignature

An esignature shibboleth module
MIT License
0 stars 0 forks source link

shibboleth_esignature_v1.0.3 module not working with record_id's of 2 and above (Only record_id 1 works) #2

Open nsimbi opened 1 year ago

nsimbi commented 1 year ago

Hi Andy, I am using Shibboleth and SAML as the authentication mechanism on our REDCap server. As a result, I also installed this e-signature module. Thanks for detailing its usage.

However, after enabling it, I tried to test and only the record with id 1, was successfully locked and signed. I did further testing, compared with file esignature.js, and found a pattern on every project I created. So I looked at the code for the module, specifically, https://github.com/susom/redcap-em-shibboleth-esignature/blob/master/esignature.js from line 110

On constant testing and looking at the code, I realized that the following

  1. The module allows e-signing on the first record of a project correctly, (record ID 1)
  2. Throws an error (An error occurred) on the second record. (record ID 2)
  3. All other trials to e-sign records that are not record_id 1 or 2 fail but don't return anything (Lock and e-sign, reauthenticate with Identity Provider, but after returning, the record is not closed so in summary, you are stuck in a loop)

So I have modified the code to work as it does on record id 1 of every project (replacing lines 125-158 of esignature.js with the code below)

function(data) { ShibEsig.popup.dialog('close'); if (data !== "") { // If response is not empty, e-signature was saved ShibEsig.numLogins = 0; // Submit the form if saving e-signature if (ShibEsig.lock_action === 'lock' || ShibEsig.lock_action == '') { formSubmitDataEntry(); } else { setUnlocked("save"); } } else { alert("An error has occurred."); } Now e-signature works on all records, of all projects.

I can submit a pull request for this as well unless there is some implementation I missed to make his module work without any adjustments.

123andy commented 1 year ago

Hello @nsimbi - The issue was related to a change Rob made to the core redcap code at version 12.5.4 -- so I assume you are using REDCap 12.5.4 or higher? I believe I just posted a fix. Can you test and let me know?

nsimbi commented 1 year ago

Yes, @123andy I am running version 12.5.4, I will test out the newest version of the module and revert. Thanks!

krobertson71 commented 1 year ago

Sorry I am coming into this very late. I wanted to update you that issue was not limited to 12.5.4 and up. We had the same issue with 12.4.12 (php 8 & mysql 8). We manually applied the fix presented by @nsimbi which solved our same issue he was having. We cannot update to a newer version as we are running 12.4.31 (Started in 12.4.12 then we upgraded to 12.4.31 and had same issue and applied same fix w/ success). We have encountered another issue and I am posting that separately from this. Just FYI that this issue occurred for us before in earlier versions