Skip to content
This repository has been archived by the owner on Jun 12, 2024. It is now read-only.

Commit

Permalink
Merge pull request #669 from theywa/6.0.0.oc
Browse files Browse the repository at this point in the history
fixed: disable external-signature feature in previews, #667
  • Loading branch information
kkrumlian authored Mar 21, 2023
2 parents 7cc3142 + 119d000 commit 95bd039
Showing 1 changed file with 64 additions and 51 deletions.
115 changes: 64 additions & 51 deletions public/js/src/module/controller-webform-oc.js
Original file line number Diff line number Diff line change
Expand Up @@ -1315,64 +1315,77 @@ function _setFormEventHandlers() {
);
}

form.view.html.addEventListener(
events.SignatureRequested().type,
(event) => {
const resetQuestion = () => {
event.target.checked = false;
event.target.dispatchEvent(events.Change());
};
if (settings.type !== 'preview') {
form.view.html.addEventListener(
events.SignatureRequested().type,
(event) => {
const resetQuestion = () => {
event.target.checked = false;
event.target.dispatchEvent(events.Change());
};

form.validate().then((valid) => {
if (valid) {
let timeoutId;
const receiveMessage = (evt) => {
// TODO: remove this temporary logging
console.log(
`evt.origin: ${evt.origin}, settings.parentWindowOrigin: ${settings.parentWindowOrigin}`
);
console.log('msg received: ', JSON.parse(evt.data));
if (evt.origin === settings.parentWindowOrigin) {
const msg = JSON.parse(evt.data);
if (msg.event === 'signature-request-received') {
clearTimeout(timeoutId);
} else if (
msg.event === 'signature-request-failed'
) {
clearTimeout(timeoutId);
resetQuestion();
window.removeEventListener(
'message',
receiveMessage
form.validate().then((valid) => {
if (valid) {
let timeoutId;
const receiveMessage = (evt) => {
// TODO: remove this temporary logging
console.log(
`evt.origin: ${evt.origin}, settings.parentWindowOrigin: ${settings.parentWindowOrigin}`
);
console.log('msg received: ', JSON.parse(evt.data));
if (evt.origin === settings.parentWindowOrigin) {
const msg = JSON.parse(evt.data);
if (
msg.event === 'signature-request-received'
) {
clearTimeout(timeoutId);
} else if (
msg.event === 'signature-request-failed'
) {
clearTimeout(timeoutId);
resetQuestion();
window.removeEventListener(
'message',
receiveMessage
);
}
} else {
console.error(
'message received from untrusted source'
);
}
} else {
console.error(
'message received from untrusted source'
};
const failHandler = () => {
resetQuestion();
window.removeEventListener(
'message',
receiveMessage
);
}
};
const failHandler = () => {
gui.alert(
t(
'fieldsubmission.alert.signatureservicenotavailable.msg'
)
);
};
timeoutId = setTimeout(failHandler, 3 * 1000);
window.addEventListener(
'message',
receiveMessage,
false
);
rc.postEventAsMessageToParentWindow(event);
} else {
// If this logic becomes complex, with autoqueries, rfc e.g., consider using
// code in the _complete or _close functions to avoid duplication
resetQuestion();
window.removeEventListener('message', receiveMessage);
gui.alert(
t(
'fieldsubmission.alert.signatureservicenotavailable.msg'
)
t('fieldsubmission.alert.participanterror.msg')
);
};
timeoutId = setTimeout(failHandler, 3 * 1000);
window.addEventListener('message', receiveMessage, false);
rc.postEventAsMessageToParentWindow(event);
} else {
// If this logic becomes complex, with autoqueries, rfc e.g., consider using
// code in the _complete or _close functions to avoid duplication
resetQuestion();
gui.alert(t('fieldsubmission.alert.participanterror.msg'));
}
});
}
);
}
});
}
);
}

// Before repeat removal from view and model
if (settings.reasonForChange) {
Expand Down

0 comments on commit 95bd039

Please sign in to comment.