Giter VIP home page Giter VIP logo

Comments (18)

aldeed avatar aldeed commented on July 30, 2024 1

Actually Meteor.user() is undefined, too

from meteor-roles.

aldeed avatar aldeed commented on July 30, 2024 1

@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.

aldeed avatar aldeed commented on July 30, 2024

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.

alanning avatar alanning commented on July 30, 2024

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.

alanning avatar alanning commented on July 30, 2024

@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.

aldeed avatar aldeed commented on July 30, 2024

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.

jhuenges avatar jhuenges commented on July 30, 2024

Any updates?

from meteor-roles.

alanning avatar alanning commented on July 30, 2024

@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.

jhuenges avatar jhuenges commented on July 30, 2024

I ll take a look at it next week

from meteor-roles.

rhyslbw avatar rhyslbw commented on July 30, 2024

This appears to be resolved now

from meteor-roles.

jhuenges avatar jhuenges commented on July 30, 2024

@rhyslbw what versions of the roles package and iron router are you using?

from meteor-roles.

rhyslbw avatar rhyslbw commented on July 30, 2024

@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.

jhuenges avatar jhuenges commented on July 30, 2024

Thanks, I ll check it out!

from meteor-roles.

leebenson avatar leebenson commented on July 30, 2024

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.

leebenson avatar leebenson commented on July 30, 2024

@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.

leebenson avatar leebenson commented on July 30, 2024

Created pull request #88

from meteor-roles.

juliomac avatar juliomac commented on July 30, 2024

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.

alanning avatar alanning commented on July 30, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.