From 6ccc5a62bfa7c2c6bf7b2c5b0c5926835b301903 Mon Sep 17 00:00:00 2001 From: Fabien Franzen Date: Fri, 22 Aug 2014 22:18:24 +0200 Subject: [PATCH] Account for undefined before/afterListeners --- lib/models/model.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/models/model.js b/lib/models/model.js index 6694ac55..e4414505 100644 --- a/lib/models/model.js +++ b/lib/models/model.js @@ -637,12 +637,12 @@ Model.nestRemoting = function(relationName, options, cb) { var before = method.isStatic ? beforeListeners : beforeListeners['prototype']; var after = method.isStatic ? afterListeners : afterListeners['prototype']; var m = method.isStatic ? method.name : 'prototype.' + method.name; - if (before[delegateTo]) { + if (before && before[delegateTo]) { self.beforeRemote(m, function(ctx, result, next) { before[delegateTo]._listeners.call(null, ctx, next); }); } - if (after[delegateTo]) { + if (after && after[delegateTo]) { self.afterRemote(m, function(ctx, result, next) { after[delegateTo]._listeners.call(null, ctx, next); });