ensure apply only on server

This commit is contained in:
Nacho Codoñer
2024-05-29 18:02:25 +02:00
parent 12c7ce7ec5
commit c93f45f238

View File

@@ -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);