feat: Collection admins (#5273
* Split permissions for reading documents from updating collection * fix: Admins should have collection read permission, tests * tsc * Add admin option to permission selector * Combine publish and create permissions, update -> createDocuments where appropriate * Plural -> singular * wip * Quick version of collection structure loading, will revisit * Remove documentIds method * stash * fixing tests to account for admin creation * Add self-hosted migration * fix: Allow groups to have admin permission * Prefetch collection documents * fix: Document explorer (move/publish) not working with async documents * fix: Cannot re-parent document to collection by drag and drop * fix: Cannot drag to import into collection item without admin permission * Remove unused isEditor getter
This commit is contained in:
@@ -98,7 +98,7 @@ router.post(
|
||||
const collection = await Collection.scope({
|
||||
method: ["withMembership", user.id],
|
||||
}).findByPk(collectionId);
|
||||
authorize(user, "read", collection);
|
||||
authorize(user, "readDocument", collection);
|
||||
|
||||
// index sort is special because it uses the order of the documents in the
|
||||
// collection.documentStructure rather than a database column
|
||||
@@ -342,7 +342,7 @@ router.post(
|
||||
const collection = await Collection.scope({
|
||||
method: ["withMembership", user.id],
|
||||
}).findByPk(collectionId);
|
||||
authorize(user, "read", collection);
|
||||
authorize(user, "readDocument", collection);
|
||||
}
|
||||
|
||||
const collectionIds = collectionId
|
||||
@@ -599,7 +599,7 @@ router.post(
|
||||
}
|
||||
|
||||
if (document.collection) {
|
||||
authorize(user, "update", collection);
|
||||
authorize(user, "updateDocument", collection);
|
||||
}
|
||||
|
||||
if (document.deletedAt) {
|
||||
@@ -686,7 +686,7 @@ router.post(
|
||||
const collection = await Collection.scope({
|
||||
method: ["withMembership", user.id],
|
||||
}).findByPk(collectionId);
|
||||
authorize(user, "read", collection);
|
||||
authorize(user, "readDocument", collection);
|
||||
}
|
||||
|
||||
if (userId) {
|
||||
@@ -780,7 +780,7 @@ router.post(
|
||||
const collection = await Collection.scope({
|
||||
method: ["withMembership", user.id],
|
||||
}).findByPk(collectionId);
|
||||
authorize(user, "read", collection);
|
||||
authorize(user, "readDocument", collection);
|
||||
}
|
||||
|
||||
let collaboratorIds = undefined;
|
||||
@@ -921,7 +921,7 @@ router.post(
|
||||
method: ["withMembership", user.id],
|
||||
}).findByPk(collectionId!);
|
||||
}
|
||||
authorize(user, "publish", collection);
|
||||
authorize(user, "createDocument", collection);
|
||||
}
|
||||
|
||||
collection = await sequelize.transaction(async (transaction) => {
|
||||
@@ -982,7 +982,7 @@ router.post(
|
||||
const collection = await Collection.scope({
|
||||
method: ["withMembership", user.id],
|
||||
}).findByPk(collectionId);
|
||||
authorize(user, "update", collection);
|
||||
authorize(user, "updateDocument", collection);
|
||||
|
||||
if (parentDocumentId) {
|
||||
const parent = await Document.findByPk(parentDocumentId, {
|
||||
@@ -1205,7 +1205,7 @@ router.post(
|
||||
teamId: user.teamId,
|
||||
},
|
||||
});
|
||||
authorize(user, "publish", collection);
|
||||
authorize(user, "createDocument", collection);
|
||||
let parentDocument;
|
||||
|
||||
if (parentDocumentId) {
|
||||
@@ -1282,7 +1282,7 @@ router.post(
|
||||
teamId: user.teamId,
|
||||
},
|
||||
});
|
||||
authorize(user, "publish", collection);
|
||||
authorize(user, "createDocument", collection);
|
||||
}
|
||||
|
||||
let parentDocument;
|
||||
|
||||
Reference in New Issue
Block a user