Skip to content
This repository has been archived by the owner on May 5, 2020. It is now read-only.

1.3.0 not working with Meteor.roles #34

Closed
PhilippSpo opened this issue Oct 12, 2015 · 4 comments
Closed

1.3.0 not working with Meteor.roles #34

PhilippSpo opened this issue Oct 12, 2015 · 4 comments

Comments

@PhilippSpo
Copy link

First of all, thanks for this package! 馃槂
This line used to work before 1.3.0:

Security.permit(['insert', 'remove', 'update']).collections([Meteor.roles]).ifHasRole('admin').apply();

I think this line is responsible for the error and I think that this issue is related to #23

@PhilippSpo PhilippSpo changed the title 1.3.0 working with Meteor.roles 1.3.0 not working with Meteor.roles Oct 12, 2015
@brylie
Copy link

brylie commented Mar 2, 2016

We are experiencing a similar problem with Meteor 1.2. We get the following error trace in the console:

TypeError: Cannot convert null to object
     at hasOwnProperty (native)
     at Function._.has (packages/underscore/underscore.js:1072:1)
     at packages/ongoworks_security/lib/server/security-util.js:54:1
     at packages/underscore/underscore.js:208:1
     at Array.filter (packages/es5-shim/.npm/package/node_modules/es5-shim/es5-shim.js:479:1)
     at Function._.filter._.select (packages/underscore/underscore.js:198:1)
     at Function._.reject (packages/underscore/underscore.js:207:1)
     at packages/ongoworks_security/lib/server/security-util.js:53:1
     at Array.forEach (packages/es5-shim/.npm/package/node_modules/es5-shim/es5-shim.js:417:1)
     at Function._.each._.forEach (packages/underscore/underscore.js:105:1)

Things work fine when commenting out any lines that call ifHasRole.

@cdeadlock
Copy link

Is there a workaround?

@cdeadlock
Copy link

Tried to make my own method, still doesn't work, I am not sure its really related to Role functionality?

Security.defineMethod('ifRole', {
  fetch: [],
  transform: null,
  deny: function (type, arg, userId) {
    console.log('deny');
    console.log(arg);
    return !Roles.userIsInRole(userId, [arg]);
  }
});

Items.permit(['insert','update','delete']).ifRole('admin').apply();
=> Exited with code: 8
W20160324-16:40:27.389(-6)? (STDERR) 
W20160324-16:40:27.389(-6)? (STDERR) C:\Users\video\AppData\Local\.meteor\packages\meteor-tool\1.1.10\mt-os.windows.x86_32\dev_bundle\server-lib\node_modules\fibers\future.js:245
W20160324-16:40:27.389(-6)? (STDERR)                        throw(ex);
W20160324-16:40:27.389(-6)? (STDERR)                              ^
W20160324-16:40:27.389(-6)? (STDERR) TypeError: Cannot convert null to object
W20160324-16:40:27.389(-6)? (STDERR)     at hasOwnProperty (native)
W20160324-16:40:27.389(-6)? (STDERR)     at Function._.has (packages/underscore/underscore.js:1072:1)
W20160324-16:40:27.389(-6)? (STDERR)     at packages/ongoworks_security/lib/server/security-util.js:54:1
W20160324-16:40:27.389(-6)? (STDERR)     at packages/underscore/underscore.js:208:1
W20160324-16:40:27.389(-6)? (STDERR)     at Array.filter (packages/es5-shim/.npm/package/node_modules/es5-shim/es5-shim.js:479:1)
W20160324-16:40:27.389(-6)? (STDERR)     at Function._.filter._.select (packages/underscore/underscore.js:198:1)
W20160324-16:40:27.389(-6)? (STDERR)     at Function._.reject (packages/underscore/underscore.js:207:1)
W20160324-16:40:27.389(-6)? (STDERR)     at packages/ongoworks_security/lib/server/security-util.js:53:1
W20160324-16:40:27.389(-6)? (STDERR)     at Array.forEach (packages/es5-shim/.npm/package/node_modules/es5-shim/es5-shim.js:417:1)
W20160324-16:40:27.389(-6)? (STDERR)     at Function._.each._.forEach (packages/underscore/underscore.js:105:1)

@aldeed
Copy link
Contributor

aldeed commented Apr 2, 2016

Pretty sure this is fixed in 2.0, or at least I cannot reproduce it. If not, please open a new issue with a link to a simple reproduction app.

@aldeed aldeed closed this as completed Apr 2, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants