trailsjs / sails-permissions

Comprehensive user permissions and entitlements system for sails.js and Waterline. Supports user authentication with passport.js, role-based permissioning, object ownership, and row-level security.
MIT License
418 stars 113 forks source link

res.ok() #179

Open sylvainlap opened 9 years ago

sylvainlap commented 9 years ago

With sails permissions v1.4.5, if I call res.ok() without any data, I get this error:

info: responsePolicy
/home/sylvainlap/DEV/WORKSPACE/ADaM/node_modules/sails-mongo/node_modules/mongodb/lib/utils.js:98
    process.nextTick(function() { throw err; });
                                        ^
TypeError: Cannot set property '.(ørigindex)' of undefined
    at /home/sylvainlap/DEV/WORKSPACE/ADaM/node_modules/waterline-criteria/lib/query.js:56:31
    at Function.forEach (/home/sylvainlap/DEV/WORKSPACE/ADaM/node_modules/waterline-criteria/node_modules/lodash/dist/lodash.js:3298:15)
    at query (/home/sylvainlap/DEV/WORKSPACE/ADaM/node_modules/waterline-criteria/lib/query.js:55:5)
    at /home/sylvainlap/DEV/WORKSPACE/ADaM/node_modules/sails-permissions/api/policies/CriteriaPolicy.js:109:22
    at Array.some (native)
    at /home/sylvainlap/DEV/WORKSPACE/ADaM/node_modules/sails-permissions/api/policies/CriteriaPolicy.js:108:14
    at Array.reduce (native)
    at Object.responsePolicy (/home/sylvainlap/DEV/WORKSPACE/ADaM/node_modules/sails-permissions/api/policies/CriteriaPolicy.js:107:24)
    at ServerResponse.wrapper [as ok] (/home/sylvainlap/DEV/WORKSPACE/ADaM/node_modules/lodash/index.js:3592:19)
    at /home/sylvainlap/DEV/WORKSPACE/ADaM/api/controllers/PostController.js:36:13
    at wrapper (/home/sylvainlap/DEV/WORKSPACE/ADaM/node_modules/sails/node_modules/waterline/node_modules/lodash/index.js:3602:19)
    at applyInOriginalCtx (/home/sylvainlap/DEV/WORKSPACE/ADaM/node_modules/sails/node_modules/waterline/lib/waterline/utils/normalize.js:421:80)
    at wrappedCallback (/home/sylvainlap/DEV/WORKSPACE/ADaM/node_modules/sails/node_modules/waterline/lib/waterline/utils/normalize.js:320:18)
    at callback.success (/home/sylvainlap/DEV/WORKSPACE/ADaM/node_modules/sails/node_modules/waterline/node_modules/switchback/lib/normalize.js:33:31)
    at _switch (/home/sylvainlap/DEV/WORKSPACE/ADaM/node_modules/sails/node_modules/waterline/node_modules/switchback/lib/factory.js:48:28)
    at returnResults (/home/sylvainlap/DEV/WORKSPACE/ADaM/node_modules/sails/node_modules/waterline/lib/waterline/query/finders/basic.js:180:9)
    at /home/sylvainlap/DEV/WORKSPACE/ADaM/node_modules/sails/node_modules/waterline/lib/waterline/query/finders/basic.js:86:16
    at /home/sylvainlap/DEV/WORKSPACE/ADaM/node_modules/sails/node_modules/waterline/lib/waterline/query/finders/operations.js:82:7
    at /home/sylvainlap/DEV/WORKSPACE/ADaM/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:49:16
    at Object.async.forEachOf.async.eachOf (/home/sylvainlap/DEV/WORKSPACE/ADaM/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:227:20)
    at Object.async.forEach.async.each (/home/sylvainlap/DEV/WORKSPACE/ADaM/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:206:22)
    at /home/sylvainlap/DEV/WORKSPACE/ADaM/node_modules/sails/node_modules/waterline/lib/waterline/query/finders/operations.js:433:11
    at /home/sylvainlap/DEV/WORKSPACE/ADaM/node_modules/sails/node_modules/waterline/lib/waterline/query/finders/operations.js:572:5
    at /home/sylvainlap/DEV/WORKSPACE/ADaM/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:49:16
    at Object.async.forEachOf.async.eachOf (/home/sylvainlap/DEV/WORKSPACE/ADaM/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:227:20)
    at Object.async.forEach.async.each (/home/sylvainlap/DEV/WORKSPACE/ADaM/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:206:22)
    at _buildChildOpts (/home/sylvainlap/DEV/WORKSPACE/ADaM/node_modules/sails/node_modules/waterline/lib/waterline/query/finders/operations.js:461:9)
    at _execChildOpts (/home/sylvainlap/DEV/WORKSPACE/ADaM/node_modules/sails/node_modules/waterline/lib/waterline/query/finders/operations.js:429:8)
tjwebb commented 9 years ago

With sails permissions v1.4.5, if I call res.ok() without any data

does this happen in sails without sails-permissions?

sylvainlap commented 9 years ago

no, without sails permissions, I can call res.ok() without any arguments.

redBaronNc commented 8 years ago

+1 I have the same issue with sails-permissions 2.1.11

TemaSM commented 8 years ago

+1 Totally the same issue! "sails": "~0.12.7", "sails-permissions": "^2.2.0" "sails-auth": "^2.1.3",