Hello, i’ve included alanning:roles at my project as in Readme, created the users at server/init.js
//server/init.js
var users = [
{name:"Normal User",email:"normal@ehnormal.com.br",roles:[]},
{name:"Usuario Secreto",email:"mauriciord@me.com",roles:['view-secrets']},
{name:"Usuario Gerenciador",email:"mauricioreattoduarte@gmail.com",roles:['manage-users']},
{name:"Mauricio",email:"mauricio@thcm.com.br",roles:['admin']}
];
_.each(users, function (user) {
var id;
id = Accounts.createUser({
email: user.email,
password: "apple1",
profile: { name: user.name }
});
if (user.roles.length > 0) {
// Need _id of existing user record so this call must come
// after `Accounts.createUser` or `Accounts.onCreate`
// Roles.addUsersToRoles(id, user.roles, 'default-group');
Meteor.users.update({_id: id}, {$set:{'emails.0.verified': true}});
console.log("usuario criado");
Roles.addUsersToRoles(id, user.roles, 'default-group');
//Roles.addUsersToRoles(id, user.roles);
}
});
Like said in README too:
//server/publish.js
Meteor.publish(null, function (){
return Meteor.roles.find({})
});
But when i try to check User’s permission in routes.js: see all here
// lib/routes.js
var logado = FlowRouter.group({
name: 'logadoRoutes',
// se não estiver logado vai para /login
triggersEnter: [function(context, redirect) {
console.log('logado grupo');
if(!Meteor.userId()) {
FlowRouter.go('login');
} else {
return true;
}
}]
});
var admin = logado.group({
prefix: '/admin',
name: 'adminRoutes',
triggersEnter: [function(context, redirect) {
var loggedInUser = Meteor.userId();
console.log('verificando admin ...');
if (Roles.userIsInRole(loggedInUser, ['view-secrets', 'admin'], "default-group")) {
return true;
console.log('é admin - rotas');
}
console.log('não é admin - rotas');
throw new Meteor.Error(403, "Acesso Negado");
}]
});
I’m trying to check if logged user has an admin permission.
I’ve tried all the ways.
That check returns false, can anyone help me ?
My repository here: https://github.com/mauriciord/thomasicamargo
Best regards,
Mauricio