Closed FrancoisYu closed 4 years ago
@FrancoisYu I guess you have the same issue as described here: https://github.com/Meteor-Community-Packages/meteor-roles/issues/296
it seems the same to me too, version 2.1 works correctly while 3.2.2 does not recognize roles
@ after users creation: `var postSignUp = function(userId, info) { console.log(userId); console.log(info.profile.profession); Roles.addUsersToRoles(userId, ['admin']); }
AccountsTemplates.configure({ postSignUpHook: postSignUp });`
and then
` {{#if isInRole 'admin'}}
{{else}}
<h1>Not Authorized</h1>
{{/if}}
`
{{#if isInRole 'admin'}} not working properly
@fpreti please also check the issue I linked.
If the problem persists, please create a sandbox git-repository here on github and send me a link so I can dig into it.
i think that the issue that you linked it's not reflect our case, i will create a sandbox repo
@SimonSimCity https://github.com/fpreti/meteor-roles-issue-317
I've also created a very simple repo. without any UI for testing only: https://github.com/FrancoisYu/roles-test.git
Take the following steps to re-generate the error:
git clone
cd roles-test && meteor npm install
meteor
Open Chrome to access http://localhost:3000
Open the developer console, input the following command:
Meteor.loginWithPassword('test@gmail.com','test') undefined
Roles.userIsInRole(['admin']) false
Meteor.call('checkIfAdmin', (err,res)=>{console.log(res )}); true
And if you check the server console , it return true too.
@FrancoisYu Well, there's one thing you did wrong when calling it on the client side: You didn't give a user-id or an user object to the function Roles.userIsInRole()
, but on the server side you did.
It returns true
calling it like this: Roles.userIsInRole(Meteor.userId(), ['admin'])
That said, your code returns the expected result when using the command of the description you initially wrote when opening this issue.
@fpreti If you are just updating without changing anything in code, you did not read the update notices (https://github.com/Meteor-Community-Packages/meteor-roles#changes-between-2x-and-30). Please follow those steps first and open a new ticket if you still face problems.
Thanks. SimonSimCity, Now I got the "true".
I've just created a new react app. With alanning:roles@3.2, Roles.userIsInRole(Meteor.userId(),['manager']) always retun false in Chrome console, but if I downgrade to alanning:roles@2.0.1, reset the db, Roles.userIsInRole(Meteor.userId(),['manager']) return true in Chrome console,. Has anyone have the same issue?