From c93f45f2384300e4aaf78f22cd0115aca3f442eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Codo=C3=B1er?= Date: Wed, 29 May 2024 18:02:25 +0200 Subject: [PATCH] ensure apply only on server --- packages/allow-deny/allow-deny.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/allow-deny/allow-deny.js b/packages/allow-deny/allow-deny.js index 596bb801b3..20936bc3a2 100644 --- a/packages/allow-deny/allow-deny.js +++ b/packages/allow-deny/allow-deny.js @@ -187,9 +187,10 @@ CollectionPrototype._defineMutationMethods = function(options) { } const syncMethodName = method.replace('Async', ''); - // it forces to use async validated method as part of the method - const validatedMethodName = - '_validated' + method.charAt(0).toUpperCase() + syncMethodName.slice(1) + 'Async'; + const syncValidatedMethodName = '_validated' + method.charAt(0).toUpperCase() + syncMethodName.slice(1); + // it forces to use async validated behavior on the server + const validatedMethodName = Meteor.isServer ? syncValidatedMethodName + 'Async' : syncValidatedMethodName; + args.unshift(this.userId); isInsert(method) && args.push(generatedId); return self[validatedMethodName].apply(self, args);