From 4fc07fe1256c6c1b1384cbbc6af340e42404c3ac Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Mon, 22 Dec 2014 08:23:27 -0800 Subject: [PATCH 1/5] Use User.remoteMethod instead of loopbacks method This is needed for loopback-connector-remote authorization. Addresses https://github.com/strongloop/loopback/issues/622. --- common/models/user.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/common/models/user.js b/common/models/user.js index e9fee16e..2ddb219c 100644 --- a/common/models/user.js +++ b/common/models/user.js @@ -319,7 +319,7 @@ module.exports = function(User) { options.port + options.restApiRoot + userModel.http.path + - userModel.confirm.http.path + + userModel.sharedClass.find('confirm', true).http.path + '?uid=' + options.user.id + '&redirect=' + @@ -480,8 +480,8 @@ module.exports = function(User) { next(); }); - loopback.remoteMethod( - UserModel.login, + UserModel.remoteMethod( + 'login', { description: 'Login a user with username/email and password', accepts: [ @@ -502,8 +502,8 @@ module.exports = function(User) { } ); - loopback.remoteMethod( - UserModel.logout, + UserModel.remoteMethod( + 'logout', { description: 'Logout a user with access token', accepts: [ @@ -521,8 +521,8 @@ module.exports = function(User) { } ); - loopback.remoteMethod( - UserModel.confirm, + UserModel.remoteMethod( + 'confirm', { description: 'Confirm a user registration with email verification token', accepts: [ @@ -534,8 +534,8 @@ module.exports = function(User) { } ); - loopback.remoteMethod( - UserModel.resetPassword, + UserModel.remoteMethod( + 'resetPassword', { description: 'Reset password for a user with email', accepts: [ From 32ed60904c008fb1f7e5662e581109e930451423 Mon Sep 17 00:00:00 2001 From: Rand McKinney Date: Thu, 8 Jan 2015 15:24:20 -0800 Subject: [PATCH 2/5] Added context middleware --- docs.json | 1 + 1 file changed, 1 insertion(+) diff --git a/docs.json b/docs.json index 82ce432f..94373a92 100644 --- a/docs.json +++ b/docs.json @@ -10,6 +10,7 @@ "lib/model.js", "lib/persisted-model.js", { "title": "Middleware", "depth": 2 }, + "server/middleware/context.js", "server/middleware/favicon.js", "server/middleware/rest.js", "server/middleware/static.js", From 27a6c16c7389acbee66f62cbf7bf7848c02df39e Mon Sep 17 00:00:00 2001 From: Raymond Feng Date: Tue, 13 Jan 2015 10:19:53 -0800 Subject: [PATCH 3/5] Add a link to gitter chat --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 03235f8b..1ed717a0 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,7 @@ The LoopBack community has created and supports a number of additional connector * [API documentation](http://apidocs.strongloop.com/loopback). * [LoopBack Google Group](https://groups.google.com/forum/#!forum/loopbackjs). * [GitHub issues](https://github.com/strongloop/loopback/issues). + * [Gitter chat](https://gitter.im/strongloop/loopback). ## Contributing From 982e495632832729cd9f8b9945896018b085dc7b Mon Sep 17 00:00:00 2001 From: Raymond Feng Date: Thu, 15 Jan 2015 09:03:22 -0800 Subject: [PATCH 4/5] Optimize the creation of handlers for rest --- server/middleware/rest.js | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/server/middleware/rest.js b/server/middleware/rest.js index cfe9de77..c2711e36 100644 --- a/server/middleware/rest.js +++ b/server/middleware/rest.js @@ -23,27 +23,27 @@ module.exports = rest; */ function rest() { + var handlers; // Cached handlers + return function restApiHandler(req, res, next) { var app = req.app; - var restHandler = app.handler('rest'); if (req.url === '/routes') { - return res.send(restHandler.adapter.allRoutes()); + return res.send(app.handler('rest').adapter.allRoutes()); } else if (req.url === '/models') { return res.send(app.remotes().toJSON()); } - var preHandlers; - - if (!preHandlers) { - preHandlers = []; + if (!handlers) { + handlers = []; var remotingOptions = app.get('remoting') || {}; var contextOptions = remotingOptions.context; if (contextOptions !== false) { - if (typeof contextOptions !== 'object') + if (typeof contextOptions !== 'object') { contextOptions = {}; - preHandlers.push(loopback.context(contextOptions)); + } + handlers.push(loopback.context(contextOptions)); } if (app.isAuthEnabled) { @@ -54,11 +54,18 @@ function rest() { // https://github.com/strongloop/loopback/pull/167 // https://github.com/strongloop/loopback/commit/f07446a var AccessToken = loopback.getModelByType(loopback.AccessToken); - preHandlers.push(loopback.token({ model: AccessToken })); + handlers.push(loopback.token({ model: AccessToken })); } - } - async.eachSeries(preHandlers.concat(restHandler), function(handler, done) { + handlers.push(function(req, res, next) { + // Need to get an instance of the REST handler per request + return app.handler('rest')(req, res, next); + }); + } + if (handlers.length === 1) { + return handlers[0](req, res, next); + } + async.eachSeries(handlers, function(handler, done) { handler(req, res, done); }, next); }; From e4dc89338373457e2b27390a1e441002b2dac3af Mon Sep 17 00:00:00 2001 From: Raymond Feng Date: Thu, 15 Jan 2015 13:57:13 -0800 Subject: [PATCH 5/5] v2.10.1 --- CHANGES.md | 70 +++++++++++++++++++++++++++++++++++----------------- package.json | 4 +-- 2 files changed, 50 insertions(+), 24 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 7915899b..da71e90c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,15 +1,13 @@ -2015-01-08, Version 2.10.0 +2015-01-15, Version 2.10.1 ========================== - * Revert the peer dep change to avoid npm complaints (Raymond Feng) + * Optimize the creation of handlers for rest (Raymond Feng) - * Update strong-remoting dep (Raymond Feng) + * Add a link to gitter chat (Raymond Feng) - * Allow accessType per remote method (Raymond Feng) + * Added context middleware (Rand McKinney) - * API and REST tests added to ensure complete and valid credentials are supplied for verified error message to be returned - tests added as suggested and fail under previous version of User model - strongloop/loopback#931 (Ron Edgecomb) - - * Require valid login credentials before verified email check. - strongloop/loopback#931. (Ron Edgecomb) + * Use User.remoteMethod instead of loopbacks method This is needed for loopback-connector-remote authorization. Addresses https://github.com/strongloop/loopback/issues/622. (Berkeley Martinez) 2015-01-07, Version 2.9.0 @@ -25,8 +23,25 @@ 2015-01-07, Version 2.8.8 ========================= + + +2015-01-07, Version 2.10.0 +========================== + + * Revert the peer dep change to avoid npm complaints (Raymond Feng) + + * Update strong-remoting dep (Raymond Feng) + + * Allow accessType per remote method (Raymond Feng) + + * Update juggler dep (Raymond Feng) + * Fix context middleware to preserve domains (Pham Anh Tuan) + * Fix Geo test cases (Raymond Feng) + + * Allow User.hashPassword/validatePassword to be overridden (Raymond Feng) + * Additional password reset unit tests for API and REST - strongloop/loopback#944 (Ron Edgecomb) * Small formatting update to have consistency with identical logic in other areas. - strongloop/loopback#944 (Ron Edgecomb) @@ -41,6 +56,10 @@ * Update to demonstrate unit test is actually failing due to incorrect values of invalidCredentials - strongloop/loopback#944 (Ron Edgecomb) + * API and REST tests added to ensure complete and valid credentials are supplied for verified error message to be returned - tests added as suggested and fail under previous version of User model - strongloop/loopback#931 (Ron Edgecomb) + + * Require valid login credentials before verified email check. - strongloop/loopback#931. (Ron Edgecomb) + * fix jscs warning (Clark Wang) * fix nestRemoting is nesting hooks from other relations (Clark Wang) @@ -81,16 +100,19 @@ * Fix bcrypt issues for browserify (Raymond Feng) - -2014-12-08, Version 2.8.4 -========================= - * Allow native bcrypt for performance (Raymond Feng) 2014-12-08, Version 2.8.3 ========================= + + +2014-12-08, Version 2.8.4 +========================= + + * Allow native bcrypt for performance (Raymond Feng) + * Remove unused underscore dependency (Ryan Graham) @@ -1723,6 +1745,15 @@ * Improve jsdox documentation of app object (Miroslav Bajtoš) + * Make sure methods are called in the context of the calling class (Raymond Feng) + + * Start to move md to jsdoc (Ritchie Martori) + + +2014-01-14, Version 1.5.0 +========================= + + 2014-01-14, Version 1.5.1 ========================= @@ -1733,10 +1764,6 @@ * Start to move md to jsdoc (Ritchie Martori) - -2014-01-14, Version 1.5.0 -========================= - * Replace `on` with `once` in middleware examples (Miroslav Bajtoš) * Fix incorrect transports (Ritchie Martori) @@ -1849,21 +1876,20 @@ * Add Model.requireToken, default swagger to false (Ritchie Martori) - * Bump version (Raymond Feng) - * Add password reset (Ritchie Martori) -2013-12-06, Version show -======================== - - - 2013-12-06, Version 1.3.3 ========================= * Bump version (Raymond Feng) + +2013-12-06, Version show +======================== + + * Bump version (Raymond Feng) + * Make loopback-datasource-juggler a peer dep (Raymond Feng) * Add blank line before list so it lays out properly. (Rand McKinney) diff --git a/package.json b/package.json index d087afb6..afdfe202 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "loopback", - "version": "2.10.0", + "version": "2.10.1", "description": "LoopBack: Open Source Framework for Node.js", "homepage": "http://loopback.io", "keywords": [ @@ -102,6 +102,6 @@ "url": "https://github.com/strongloop/loopback/blob/master/LICENSE" }, "optionalDependencies": { - "sl-blip": "http://blip.strongloop.com/loopback@2.10.0" + "sl-blip": "http://blip.strongloop.com/loopback@2.10.1" } }