Skip to content

Commit 3d05c8e

Browse files
authored
Merge pull request #96 from solid/prevent-root-acl-delete
Prevent users from deleting their root ACLs
2 parents 8128960 + d817ed9 commit 3d05c8e

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/acl-control.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -612,14 +612,21 @@ UI.aclControl.ACLControlBox5 = function (subject, dom, noun, kb, callback) {
612612
var q = str.indexOf('//')
613613
var targetDocDir = ((q >= 0 && p < q + 2) || p < 0) ? null : str.slice(0, p + 1)
614614

615-
if (targetDocDir) {
615+
// @@ TODO: The methods used for targetIsStorage are HACKs - it should not be relied upon, and work is
616+
// @@ underway to standardize a behavior that does not rely upon this hack
617+
// @@ hopefully fixed as part of https://github.com/solid/data-interoperability-panel/issues/10
618+
const targetIsStorage = kb.holds(targetDoc, UI.ns.rdf('type'), UI.ns.space('Storage'), targetACLDoc)
619+
const targetAclIsProtected = hasProtectedAcl(targetDoc)
620+
const targetIsProtected = targetIsStorage || targetAclIsProtected
621+
622+
if (!targetIsProtected && targetDocDir) {
616623
UI.acl.getACLorDefault($rdf.sym(targetDocDir), function (ok2, p22, targetDoc2, targetACLDoc2, defaultHolder2, defaultACLDoc2) {
617624
if (ok2) {
618625
prospectiveDefaultHolder = p22 ? targetDoc2 : defaultHolder2
619626
}
620627
addDefaultButton(prospectiveDefaultHolder)
621628
})
622-
} else {
629+
} else if (!targetIsProtected) {
623630
addDefaultButton()
624631
}
625632

@@ -685,4 +692,10 @@ UI.aclControl.ACLControlBox5 = function (subject, dom, noun, kb, callback) {
685692
renderBox()
686693
return table
687694
} // ACLControlBox
695+
696+
function hasProtectedAcl (targetDoc) {
697+
// @@ TODO: This is hacky way of knowing whether or not a certain ACL file can be removed
698+
// Hopefully we'll find a better, standardized solution to this - https://github.com/solid/specification/issues/37
699+
return targetDoc.uri === targetDoc.site().uri
700+
}
688701
// ends

0 commit comments

Comments
 (0)