diff --git a/lib/application.js b/lib/application.js index 6fda62f3..b9facad0 100644 --- a/lib/application.js +++ b/lib/application.js @@ -316,17 +316,12 @@ app.enableAuth = function() { } if(Model.checkAccess) { - // Pause the request before checking access - // See https://github.com/strongloop/loopback-storage-service/issues/7 - req.pause(); Model.checkAccess( req.accessToken, modelId, method, ctx, function(err, allowed) { - // Emit any cached data events that fired while checking access. - req.resume(); if(err) { console.log(err); next(err); diff --git a/lib/models/access-token.js b/lib/models/access-token.js index 47b7a13d..85a9f5f7 100644 --- a/lib/models/access-token.js +++ b/lib/models/access-token.js @@ -2,8 +2,7 @@ * Module Dependencies. */ -var Model = require('../loopback').Model - , loopback = require('../loopback') +var loopback = require('../loopback') , assert = require('assert') , crypto = require('crypto') , uid = require('uid2') @@ -27,20 +26,21 @@ var properties = { /** * Token based authentication and access control. * - * @property id {String} Generated token ID - * @property ttl {Number} Time to live - * @property created {Date} When the token was created - * * **Default ACLs** * * - DENY EVERYONE `*` * - ALLOW EVERYONE create - * + * + * @property {String} id Generated token ID + * @property {Number} ttl Time to live in seconds + * @property {Date} created When the token was created + * * @class - * @inherits {Model} + * @inherits {PersistedModel} */ -var AccessToken = module.exports = Model.extend('AccessToken', properties, { +var AccessToken = module.exports = + loopback.PersistedModel.extend('AccessToken', properties, { acls: [ { principalType: ACL.ROLE, diff --git a/lib/models/model.js b/lib/models/model.js index 99d899b4..6694ac55 100644 --- a/lib/models/model.js +++ b/lib/models/model.js @@ -503,6 +503,13 @@ Model.scopeRemoting = function(scopeName, scope, define) { http: {verb: 'delete', path: '/' + pathName}, description: 'Deletes all ' + scopeName + ' of this model.' }); + + define('__count__' + scopeName, { + isStatic: isStatic, + http: {verb: 'get', path: '/' + pathName + '/count'}, + description: 'Counts ' + scopeName + ' of ' + this.modelName + '.', + returns: {arg: 'count', type: 'number', root: true} + }); }; Model.nestRemoting = function(relationName, options, cb) { diff --git a/package.json b/package.json index 037be4c2..211653af 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "mobile", "mBaaS" ], - "version": "2.1.1", + "version": "2.1.3", "scripts": { "test": "grunt mocha-and-karma" },