minor fix
This commit is contained in:
parent
e59ab23b3d
commit
9bfba6037e
|
@ -69,8 +69,6 @@ const CollectionListing = () => {
|
||||||
existingCollectionIds.includes(id)
|
existingCollectionIds.includes(id)
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log(existingCollectionIds);
|
|
||||||
|
|
||||||
// Add new collections that are not in account.collectionOrder and meet the specific conditions
|
// Add new collections that are not in account.collectionOrder and meet the specific conditions
|
||||||
collections.forEach((collection) => {
|
collections.forEach((collection) => {
|
||||||
if (
|
if (
|
||||||
|
@ -226,10 +224,11 @@ const renderItem = (
|
||||||
return (
|
return (
|
||||||
<div ref={provided.innerRef} {...provided.draggableProps} className="mb-1">
|
<div ref={provided.innerRef} {...provided.draggableProps} className="mb-1">
|
||||||
<div
|
<div
|
||||||
className={`${currentPath === `/collections/${collection.id}`
|
className={`${
|
||||||
|
currentPath === `/collections/${collection.id}`
|
||||||
? "bg-primary/20 is-active"
|
? "bg-primary/20 is-active"
|
||||||
: "hover:bg-neutral/20"
|
: "hover:bg-neutral/20"
|
||||||
} duration-100 flex gap-1 items-center pr-2 pl-1 rounded-md`}
|
} duration-100 flex gap-1 items-center pr-2 pl-1 rounded-md`}
|
||||||
>
|
>
|
||||||
{Icon(item as ExtendedTreeItem, onExpand, onCollapse)}
|
{Icon(item as ExtendedTreeItem, onExpand, onCollapse)}
|
||||||
|
|
||||||
|
|
|
@ -16,44 +16,11 @@ export default async function updateLinkById(
|
||||||
};
|
};
|
||||||
|
|
||||||
const collectionIsAccessible = await getPermission({ userId, linkId });
|
const collectionIsAccessible = await getPermission({ userId, linkId });
|
||||||
const targetCollectionIsAccessible = await getPermission({
|
|
||||||
userId,
|
|
||||||
collectionId: data.collection.id,
|
|
||||||
});
|
|
||||||
|
|
||||||
const memberHasAccess = collectionIsAccessible?.members.some(
|
|
||||||
(e: UsersAndCollections) => e.userId === userId && e.canUpdate
|
|
||||||
);
|
|
||||||
|
|
||||||
const isCollectionOwner =
|
const isCollectionOwner =
|
||||||
collectionIsAccessible?.ownerId === data.collection.ownerId &&
|
collectionIsAccessible?.ownerId === data.collection.ownerId &&
|
||||||
data.collection.ownerId === userId;
|
data.collection.ownerId === userId;
|
||||||
|
|
||||||
const targetCollectionsAccessible =
|
|
||||||
targetCollectionIsAccessible?.ownerId === userId;
|
|
||||||
|
|
||||||
const targetCollectionMatchesData = data.collection.id
|
|
||||||
? data.collection.id === targetCollectionIsAccessible?.id
|
|
||||||
: true && data.collection.name
|
|
||||||
? data.collection.name === targetCollectionIsAccessible?.name
|
|
||||||
: true && data.collection.ownerId
|
|
||||||
? data.collection.ownerId === targetCollectionIsAccessible?.ownerId
|
|
||||||
: true;
|
|
||||||
|
|
||||||
if (!targetCollectionsAccessible)
|
|
||||||
return {
|
|
||||||
response: "Target collection is not accessible.",
|
|
||||||
status: 401,
|
|
||||||
};
|
|
||||||
else if (!targetCollectionMatchesData)
|
|
||||||
return {
|
|
||||||
response: "Target collection does not match the data.",
|
|
||||||
status: 401,
|
|
||||||
};
|
|
||||||
|
|
||||||
const unauthorizedSwitchCollection =
|
|
||||||
!isCollectionOwner && collectionIsAccessible?.id !== data.collection.id;
|
|
||||||
|
|
||||||
const canPinPermission = collectionIsAccessible?.members.some(
|
const canPinPermission = collectionIsAccessible?.members.some(
|
||||||
(e: UsersAndCollections) => e.userId === userId
|
(e: UsersAndCollections) => e.userId === userId
|
||||||
);
|
);
|
||||||
|
@ -84,6 +51,40 @@ export default async function updateLinkById(
|
||||||
return { response: updatedLink, status: 200 };
|
return { response: updatedLink, status: 200 };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const targetCollectionIsAccessible = await getPermission({
|
||||||
|
userId,
|
||||||
|
collectionId: data.collection.id,
|
||||||
|
});
|
||||||
|
|
||||||
|
const memberHasAccess = collectionIsAccessible?.members.some(
|
||||||
|
(e: UsersAndCollections) => e.userId === userId && e.canUpdate
|
||||||
|
);
|
||||||
|
|
||||||
|
const targetCollectionsAccessible =
|
||||||
|
targetCollectionIsAccessible?.ownerId === userId;
|
||||||
|
|
||||||
|
const targetCollectionMatchesData = data.collection.id
|
||||||
|
? data.collection.id === targetCollectionIsAccessible?.id
|
||||||
|
: true && data.collection.name
|
||||||
|
? data.collection.name === targetCollectionIsAccessible?.name
|
||||||
|
: true && data.collection.ownerId
|
||||||
|
? data.collection.ownerId === targetCollectionIsAccessible?.ownerId
|
||||||
|
: true;
|
||||||
|
|
||||||
|
if (!targetCollectionsAccessible)
|
||||||
|
return {
|
||||||
|
response: "Target collection is not accessible.",
|
||||||
|
status: 401,
|
||||||
|
};
|
||||||
|
else if (!targetCollectionMatchesData)
|
||||||
|
return {
|
||||||
|
response: "Target collection does not match the data.",
|
||||||
|
status: 401,
|
||||||
|
};
|
||||||
|
|
||||||
|
const unauthorizedSwitchCollection =
|
||||||
|
!isCollectionOwner && collectionIsAccessible?.id !== data.collection.id;
|
||||||
|
|
||||||
// Makes sure collection members (non-owners) cannot move a link to/from a collection.
|
// Makes sure collection members (non-owners) cannot move a link to/from a collection.
|
||||||
if (unauthorizedSwitchCollection)
|
if (unauthorizedSwitchCollection)
|
||||||
return {
|
return {
|
||||||
|
|
Ŝarĝante…
Reference in New Issue