Comments (18)
Actually Meteor.user()
is undefined, too
from meteor-roles.
@leebenson, it still won't be correct unless this subscription is ready. So that publication should be named and the client sub handle should be exported. Yes, we could publish the roles field in a separate pub/sub, but that seems inefficient if the roles pkg is already publishing it.
from meteor-roles.
So based on that, it seems like an iron:router regression. I've submitted an issue there, but I'll keep this one open for now, too.
from meteor-roles.
Thanks Eric. One thing that is sorely lacking from the roles repo is an example that uses "iron:router". If you would like to contribute a simple example app, that would definitely be a big help. It would also give us a base to test with when trying out new releases.
On Sep 30, 2014, at 8:01 AM, Eric Dobbertin [email protected] wrote:
So based on that, it seems like an iron:router regression. I've submitted an issue there, but I'll keep this one open for now, too.
—
Reply to this email directly or view it on GitHub.
from meteor-roles.
@aldeed, naming the subscription is fine with me if that will solve the issue. Won't help the underlying cause of no way to wait on "null" published collections of course but that's for MDG. :-)
Feel like making the change or want me to do it?
from meteor-roles.
I wonder if Meteor.subscribe(null)
returns a handle for all null
subs? I haven't tried it yet.
It will be a little while before I'd have time to submit a PR, so feel free to make the change, or I will get around to it eventually.
from meteor-roles.
Any updates?
from meteor-roles.
@jhuenges, just needs some love (ie. precious, precious time). This is still good-to-go if you'd like to submit a PR.
from meteor-roles.
I ll take a look at it next week
from meteor-roles.
This appears to be resolved now
from meteor-roles.
@rhyslbw what versions of the roles package and iron router are you using?
from meteor-roles.
@jhuenges
Meteor 1.0.3.1
iron:router 1.0.7
alanning:roles 1.2.13
I haven't actually tested this in isolation, and there is probably a long enough delay in my case to hide the problem.
from meteor-roles.
Thanks, I ll check it out!
from meteor-roles.
Try changing the doc's example server-side publication to:
Meteor.publish('roles', function (){
return Meteor.roles.find({});
});
And then client-side, in Iron Router's waitOn()
...
return Meteor.subscribe('roles');
That should wait for the full role list, so Roles.userIsInRole
works correctly in onBeforeAction()
from meteor-roles.
@aldeed I see, didn't realise this was already explicitly published. For sure it needs naming to play nicely with packages that need to wait for subscriptions. Simple oneline fix. @alanning ?
from meteor-roles.
Created pull request #88
from meteor-roles.
The pub/sub solution from @leebenson also worked for me. Thanks for it!
As for an up-to-date example for usage with iron-router, that would definitely be a good think. Meteor is evolving so quickly that it is like shooting on a moving target. None of the examples here or on StackHolder worked for me. I tested with this.pause(), render() or redirect() and finally got one working with Router.go(). Hope this helps someone else:
Router.route('/Client/Admin',
{
name: 'Admin',
template: 'Admin',
layoutTemplate:"layoutWithoutNav" ,
onBeforeAction: function() {
if (!(Meteor.userId())) {
console.log("It is not logged-in");
Router.go('atSignIn');
}
else if (!(Roles.userIsInRole(Meteor.userId(),['Admin']))){
alert("need to be an Admin");
console.log("Not an Admin");
Router.go('home');
}
else this.next();
}
from meteor-roles.
Thanks @juliomac. I did add both an iron-router and flow-router example recently but they are pretty simple so I don't think they run into this problem. Happy to accept updates that make the examples more realistic.
I'll be consolidating PRs and should be able to release a new version in around a month that will include Lee's PR. I'm also working on the design of roles 2.0 so if you have any requests, please open a new issue so we can discuss.
from meteor-roles.
Related Issues (20)
- Defaut publication uses only user._id, but no index is created on that field only HOT 2
- cannot add data into role-assignment HOT 3
- Meteor.roleAssignment, error: Property 'roleAssignment' does not exist on type 'typeof Meteor'. HOT 5
- Weird issue with role-assignement.. HOT 2
- Upgrading from 3.4.0 to 3.5.0 introduces 6x node "UnhandledPromiseRejectionWarning: TypeError: Cannot set property 'isCalledFromAsync' of undefined" warnings. HOT 1
- TypeError: Cannot set property 'isCalledFromAsync' of undefined ... HOT 4
- Improve community standards HOT 1
- Add code quality tools HOT 2
- Add selector to Roles.getUsersInRole HOT 2
- forwardMigrate2 tries to drop unset index HOT 1
- Add new function to change scope of existing role assignment HOT 1
- addRolesToParent -> Reset inheritance as unwanted roles may still be connected HOT 1
- Get a list of users with a scope HOT 13
- api docs still show v.3.4.0 in upper right corner HOT 1
- Not async? HOT 3
- Dependency on old [email protected] (need v3.0.0-rc300.1) HOT 3
- Roles.createRole is not a function (alanning:[email protected]) HOT 4
- Alpha 3 not compatible with Meteor 3 rc2 HOT 3
- Example app with selectable permissions HOT 4
- Package.alanning:roles.Roles._forwardMigrate2 is not a function HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from meteor-roles.