From bf9ebaf57c8286ff4ffe7003c6060da3e59d0f2d Mon Sep 17 00:00:00 2001 From: Eric Burel Date: Sat, 3 Mar 2018 23:11:33 +0100 Subject: [PATCH] Allow guests to create document as a default Hi, using when using the default mutations, you can't allow a guest user to create a document, even if you allowed it for `guests` when setting up permissions. This is because a undefined `user` will always trigger a `false` during the "new" check. I think it is safe to remove this, because anyway you have to manually tell who can create document (or so I think, maybe I'm wrong?) so you can't allow guests to create documents by mistake. --- packages/vulcan-core/lib/modules/default_mutations.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/vulcan-core/lib/modules/default_mutations.js b/packages/vulcan-core/lib/modules/default_mutations.js index 2a935dc71..6105864f3 100644 --- a/packages/vulcan-core/lib/modules/default_mutations.js +++ b/packages/vulcan-core/lib/modules/default_mutations.js @@ -27,9 +27,7 @@ export const getDefaultMutations = (collectionName, options = {}) => { if (options.newCheck) { return options.newCheck(user, document); } - // if user is not logged in, disallow operation - if (!user) return false; - // else, check if they can perform "foo.new" operation (e.g. "movies.new") + // check if they can perform "foo.new" operation (e.g. "movies.new") return Users.canDo(user, `${collectionName.toLowerCase()}.new`); }, @@ -244,4 +242,4 @@ const registerCollectionCallbacks = collectionName => { returns: null, description: `Perform operations on a document after it's removed from the database asynchronously.` }); -} \ No newline at end of file +}