From 38f4748021b5ae6b9f0fd57d16bddb422ebbdfd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Wed, 5 Feb 2014 18:46:22 +0100 Subject: [PATCH] Add app.isAuthEnabled. The flag is set by `app.enableAuth` and can be used to detect whether the access control is enabled. --- lib/application.js | 4 +++- test/app.test.js | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/application.js b/lib/application.js index d616e1c00..ed0733e0b 100644 --- a/lib/application.js +++ b/lib/application.js @@ -305,7 +305,9 @@ app.enableAuth = function() { next(); } }); -} + + this.isAuthEnabled = true; +}; /** * Initialize an application from an options object or a set of JSON and JavaScript files. diff --git a/test/app.test.js b/test/app.test.js index eed3d7aac..701d22fe7 100644 --- a/test/app.test.js +++ b/test/app.test.js @@ -400,6 +400,14 @@ describe('app', function() { }); }); + describe('enableAuth', function() { + it('should set app.isAuthEnabled to true', function() { + expect(app.isAuthEnabled).to.not.equal(true); + app.enableAuth(); + expect(app.isAuthEnabled).to.equal(true); + }); + }); + describe('app.get("/", loopback.status())', function () { it('should return the status of the application', function (done) { var app = loopback();