From 07a04b71da1a87e3bb5e58b6bbf41d88256a56e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Wed, 31 Aug 2016 15:21:39 +0200 Subject: [PATCH] app.enableAuth: correctly detect attached models Fix a typo in "app.enableAuth" that caused the method to not detect the situation when e.g. the built-in User model is already attached to a datasource. --- lib/application.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/application.js b/lib/application.js index f5df7871..61015f3b 100644 --- a/lib/application.js +++ b/lib/application.js @@ -327,8 +327,10 @@ app.enableAuth = function(options) { g.f('Authentication requires model %s to be defined.', m)); } - if (m.dataSource || m.app) return; + if (Model.dataSource || Model.app) return; + // Find descendants of Model that are attached, + // for example "Customer" extending "User" model for (var name in appModels) { var candidate = appModels[name]; var isSubclass = candidate.prototype instanceof Model;