8000 FIO-7759 File Export Decryption Bug Fix by Dmeeks512 · Pull Request #1870 · formio/formio · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

FIO-7759 File Export Decryption Bug Fix #1870

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

Open
wants to merge 1 commit into
base: master
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
21 changes: 11 additions & 10 deletions src/export/export.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ module.exports = (router) => {
// Array for promises
const promises = [];

_.each(data, (field, key) => {
router.formio.util.eachComponentData(form.components, data, (component, data, row, path) => {
const field = _.get(data, path);

if (field && field._id) {
// Add data property for resource fields
promises.push(
Expand All @@ -165,21 +167,20 @@ module.exports = (router) => {

// Recurse for nested resources
return addSubData(result.data)
.then(res => newData[key] = {data: res});
.then(res => _.set(newData, path, {data: res}));
})
.catch((error) => {
debug(error);
newData[key] = field;
_.set(newData, path, field);
})
);
}
else {
if (req.encryptedComponents && Object.keys(req.encryptedComponents).includes(key) && field) {
newData[key] = hook.alter('decrypt', req, field);
}
else {
newData[key] = field;
}
else if (component.encrypted && field) {
const result = hook.alter('decrypt', req, field);
_.set(newData, path, result);
}
else if (Object.keys(data).includes(path)) {
newData[path] = data[path];
}
});
await Promise.all(promises);
Expand Down
16 changes: 16 additions & 0 deletions src/util/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,22 @@ const Utils = {
*/
eachComponent: Formio.Utils.eachComponent.bind(Formio.Utils),

/**
* Iterates through each component as well as its data.
* with the contextual data for that component in addition to the absolute path for that component.
*
* @param {Object} components
* The array of JSON components to iterate through.
* @param {Object} data
* The contextual data object for the components.
* @param {Function} fn
* The callback function to trigger for each component following the signature (component, data, row, path, components, index, parent).
* @param {Object} parent
* The parent component.
* @param {Boolean} includeAll
*/
eachComponentData: Formio.Utils.eachComponentData.bind(Formio.Utils),

/**
* Get a component by its key
*
Expand Down
Loading
0