diff --git a/lib/application.js b/lib/application.js index 6f6cb682..ea104960 100644 --- a/lib/application.js +++ b/lib/application.js @@ -328,8 +328,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; diff --git a/test/user.test.js b/test/user.test.js index 0ac361bf..c638f41b 100644 --- a/test/user.test.js +++ b/test/user.test.js @@ -66,7 +66,6 @@ describe('User', function() { app.enableAuth({ dataSource: 'db' }); app.use(loopback.token({ model: AccessToken })); app.use(loopback.rest()); - app.model(User); User.create(validCredentials, function(err, user) { if (err) return done(err);