Meteor React Accounts Collection

#1

I used Accounts from the Accounts-base to handle the Login Part of the App. But I need to introduce Roles(Customer , Lender) also in the Application So after the User Login I check the User already have the Role alloted or not If alloted I routed him to the respected routes and if the not alloted role then i route the app to a page which ask the user to select the Role which he wants when the User Select the Role i use the Meteor.Users.update({_id : Meteor.User()._id} and set the role. which is successfully updated in the User Accounts also. But the Problem is when I refresh the App Accounts.onLogin function again runs and it found *No role with the User Account and again route it to the same page which ask for the Role. Don’t know why the role is not there in the User collection even after I updated the User Collection. I don’t know how to use onCreateuser for this because it actually runs for 1 time (when user create account ) which can solve my problem but I don’t know how to use it.

#2

How are you introducing the roles? are you using alanning:roles?

If not, you need make sure to publish the roles as they do.

#3

No I m not using alanning roles right now. I just add the field of Role in the User Collection.
But I didn’t remove the Meteor Autopublish, then also its necessary to publish it to get it work in the client?

#4

I personally have followed the content of the guide when doing roles, you can find some relevant info here. But to answer your question, yes unless you put that in the profile object of the user.

1 Like