Skip to content

Commit

Permalink
fix: adds backend check for if resource categories exist prior to move
Browse files Browse the repository at this point in the history
  • Loading branch information
gweiying committed Mar 24, 2021
1 parent edf8363 commit 5d09a06
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions routes/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ async function moveResources (req, res, next) {
const ResourceRoomInstance = new ResourceRoom(accessToken, siteName)
const resourceRoomName = await ResourceRoomInstance.get()

const IsomerResource = new Resource(accessToken, siteName)
const resources = await IsomerResource.list(resourceRoomName)
const resourceCategories = resources.map(resource => resource.dirName)
if (!resourceCategories.includes(resourceName)) throw new NotFoundError(`Resource category ${resourceName} was not found!`)
if (!resourceCategories.includes(newResourceName)) throw new NotFoundError(`Resource category ${newResourceName} was not found!`)

const oldIsomerFile = new File(accessToken, siteName)
const newIsomerFile = new File(accessToken, siteName)
const oldResourcePageType = new ResourcePageType(resourceRoomName, resourceName)
Expand Down

0 comments on commit 5d09a06

Please sign in to comment.