Files
wekan/models/lib/personalDataExportAccess.js
T
Lauri Ojansivu 7a25e33ca7 Download my data: everything WeKan holds about a person, as a ZIP of JSON.
Member Settings / Download my data and GET /api/user/export give the
signed-in person their account without secrets and every row of every
collection the personal-data inventory says holds their data, with a
manifest of what is in it and what is not, and why. Of a shared board, card
or list only their own part. Secrets are removed at every depth. An
administrator can export any account with userId=, recorded in the Audit
log. The menu label is translated in every language (docs/Compliance/README.md
WP-5; WP-4 recorded there too).

Thanks to xet7 !
2026-11-24 01:57:14 +02:00

25 lines
1002 B
JavaScript

'use strict';
// Who may download whose personal-data export (WP-5). Pure, so the decision
// is tested on its own (tests/personalDataExport.test.cjs).
//
// A person: their own, always - the right of access is not a setting.
// An administrator: any account's, as well - recorded in the Audit log.
// Nobody else, and nobody signed out or disabled.
const ID = /^[A-Za-z0-9]{1,64}$/;
function decideExportTarget(requester, wantedUserId) {
if (!requester || !requester._id || requester.loginDisabled) {
return { allowed: false, code: 401, error: 'not-authorized' };
}
if (!wantedUserId || wantedUserId === requester._id) {
return { allowed: true, self: true, userId: requester._id };
}
if (!ID.test(wantedUserId)) return { allowed: false, code: 400, error: 'invalid-user-id' };
if (requester.isAdmin !== true) return { allowed: false, code: 403, error: 'not-authorized' };
return { allowed: true, self: false, userId: wantedUserId };
}
module.exports = { decideExportTarget };