Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.
Prev Previous commit
Next Next commit
use Array.prototype.some() instead of ...map().includes()
  • Loading branch information
yiyione committed Jun 10, 2021
commit a8ef12743f518def02925f568ef6e9863eb1d2d3
6 changes: 2 additions & 4 deletions rest_server/src/controllers/item_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ async function checkReadPermission(userInfo, item, categories) {
if (categories === undefined) {
categories = await MarketplaceItem.getCategories(item);
}
const categoriesArray = categories.map(category => category.name);
if (
!categoriesArray.includes(OFFICIAL_EXAMPLE) &&
!categories.some(category => category.name === OFFICIAL_EXAMPLE) &&
userInfo.username === item.author
) {
return true;
Expand All @@ -43,9 +42,8 @@ async function checkWritePermission(tokenInfo, item, categories) {
if (categories === undefined) {
categories = await MarketplaceItem.getCategories(item);
}
const categoriesArray = categories.map(category => category.name);
if (
!categoriesArray.includes(OFFICIAL_EXAMPLE) &&
!categories.some(category => category.name === OFFICIAL_EXAMPLE) &&
tokenInfo.username === item.author
) {
return true;
Expand Down