reactioncommerce / reaction

Mailchimp Open Commerce is an API-first, headless commerce platform built using Node.js, React, GraphQL. Deployed via Docker and Kubernetes.
https://mailchimp.com/developer/open-commerce/
GNU General Public License v3.0
12.34k stars 2.17k forks source link

Cannot upload images to products #4018

Closed brent-hoover closed 6 years ago

brent-hoover commented 6 years ago

Issue Description

If you attempt to upload an image to a product you receive the following error on both the server and the client:

Exception while invoking method 'FileCollection/INSERT/Media' Error: Match error: Expected string, got undefined
    at check (packages/check/match.js:35:15)
    at Object.getUserShopId (server/api/core/core.js:444:5)
    at Object.allow (server/startup/collection-security.js:50:33)
    at _.every.restriction (packages/ongoworks:security/lib/server/Security.Rule.js:84:37)
    at Array.every (<anonymous>)
    at Function._.every._.all (packages/underscore.js:253:62)
    at Security.Rule.js.Security.Rule.allow (packages/ongoworks:security/lib/server/Security.Rule.js:61:14)
    at _.any.rule (packages/ongoworks:security/lib/server/Security.Check.js:91:38)
    at Array.some (<anonymous>)

Steps to Reproduce

  1. Create a product and publish
  2. Attempt to upload an image
  3. Observe the Match error on both server and client

Possible Solution

Probably also related to getShopId

Versions

Node: 8.9.4 NPM: 5.6.0 Meteor Node: 8.9.4 Meteor NPM: 5.6.0 Reaction CLI: 0.29.0 Reaction: 1.10.0 Reaction branch: release-1.10.0 Docker: 17.12.0-ce

aldeed commented 6 years ago

I think I see the issue. In https://github.com/reactioncommerce/reaction/pull/3510/files, the changes in collection-security.js are using this.userId when they should be using userId.

brent-hoover commented 6 years ago

Closed via #4029