Closed VansonLeung closed 7 years ago
Looks good. Just need to make that update to the docs I mentioned in the line comments, and add tests to verify the functionality. Try to give solid test coverage, or you'll have to resubmit again (so make sure you test it alongside auth requirement, as well as by itself).
Thank you, I will try to set the tests too
I'm closing this as it's a year old and appears to have gone stale. I'm happy to reopen it if anyone needs this feature and would like to finish up the PR.
Add 'authOptional' to optionally require login auth, if user is logged in, then endpoint 'this.user' & 'this.userId' exists. If not logged in / auth error, endpoint 'this.user' & 'this.userId' will be undefined. User is still accessible to the API but as a guest then. This allows more granular control over custom API authentication. e.g. When querying shops by Shops.find(), Members can know whether they have favorited a Shop by Favorites.find({shop_id: doc._id, user_id: self.userId}).count > 0 in collection.transform, while guests will just show shop list, as userId is undefined for guests.