fix: merge main, address code review feedback for security fix PR #816
- Merge origin/main into branch (resolve conflict in integrations_dashboard.html) - Add defensive JSON parsing with try/except for integration.config - Wrap tester() call in try/except to prevent 500 errors from bad config - Add i18n key integrations.connection_test_failed_fallback in en.json - Reference i18n key in template JS fallback message - Update SECURITY_AUDIT.md: add fix date (2026-03-23), update doc date - Remove accidental revert.sh file - Fix missing MagicMock/patch imports in test file - Add tests for invalid JSON config and tester exception error paths Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com> Agent-Logs-Url: https://github.com/christianlouis/DocuElevate/sessions/daebb70e-059a-4601-8864-88eef49f99cf
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* claim.js — Claim-ownership UI helper for unowned documents.
|
||||
*
|
||||
* Usage: call initClaimOwnership(fileId, i18n) after DOMContentLoaded.
|
||||
* The i18n object must contain:
|
||||
* confirm, success, failed
|
||||
*/
|
||||
function initClaimOwnership(fileId, i18n) {
|
||||
var btn = document.getElementById('claim-btn');
|
||||
var msg = document.getElementById('claim-msg');
|
||||
if (!btn) return;
|
||||
|
||||
btn.addEventListener('click', function () {
|
||||
if (!confirm(i18n.confirm)) return;
|
||||
btn.disabled = true;
|
||||
fetch('/api/files/' + fileId + '/claim', { method: 'POST' })
|
||||
.then(function (r) { return r.json().then(function (d) { return { ok: r.ok, data: d }; }); })
|
||||
.then(function (result) {
|
||||
if (result.ok || (result.data && result.data.status === 'already_owned')) {
|
||||
if (msg) {
|
||||
msg.textContent = i18n.success;
|
||||
msg.style.color = '#059669';
|
||||
msg.style.display = msg.tagName === 'SPAN' ? 'inline' : 'block';
|
||||
}
|
||||
setTimeout(function () { location.reload(); }, 1200);
|
||||
} else {
|
||||
if (msg) {
|
||||
msg.textContent = (result.data && result.data.detail) || i18n.failed;
|
||||
msg.style.color = '#dc2626';
|
||||
msg.style.display = msg.tagName === 'SPAN' ? 'inline' : 'block';
|
||||
}
|
||||
btn.disabled = false;
|
||||
}
|
||||
})
|
||||
.catch(function () {
|
||||
if (msg) {
|
||||
msg.textContent = i18n.failed;
|
||||
msg.style.color = '#dc2626';
|
||||
msg.style.display = msg.tagName === 'SPAN' ? 'inline' : 'block';
|
||||
}
|
||||
btn.disabled = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user