Meteor-Community-Packages / meteor-roles

Authorization package for Meteor, compatible with built-in accounts packages
http://meteor-community-packages.github.io/meteor-roles/
MIT License
921 stars 166 forks source link

Create new user and auto login, publish Roles #266

Closed lam0620 closed 4 years ago

lam0620 commented 5 years ago

Hi,

Anybody help me. I'm new meteor. In my app, when user login, the system check if user not exist, new user will be created with roles XXX, YYY(Roles.setUserRoles) and then auto login too. At home page, roles return empty (Roles.getRolesForUser(loggedInUser)) If I log out and login again, I can get correct roles.

How can I get roles of logged in user in case create new user and auto login. How can I publish created user/roles to client after role creation?

Thanks, lam0620

BobbyWalkerTech commented 5 years ago

Do you still have autopublish on your Meteor installation? If so, then the publish/subscribe methods that would normally update will not run.

lam0620 commented 5 years ago

Thanks @BobbyWalkerTech

autopublish is not a direct dependency in this project. auto login after Accounts.createUser(XXX) and the roles is empty (as above my question)

Note: When create new user and auto login case At my development mode, I can get correct roles. But on my production (built production mode), the roles is empty

It become OK (correct roles) after refresh (F5) browser.

Please help!

mitar commented 4 years ago

This should work. So a reproduction would be needed if it does not work for you.