Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permission error #48

Closed
hkirk opened this issue Aug 9, 2014 · 2 comments
Closed

Permission error #48

hkirk opened this issue Aug 9, 2014 · 2 comments

Comments

@hkirk
Copy link

hkirk commented Aug 9, 2014

First of all im not sure is the error is with Roles or the jasmine for meteor package. But my best guess is that it's here.

Im trying to write some test, where I would validate the output from a template based on the roles i've setup.

In /test/jasmine I have a function in one of my specs that creates a user and adds a role to this user.

function createUser(user) {
        Accounts.createUser({
            email: user.email,
            password: user.password,
            profile: { name: user.name }
        }, function (error) {
            if (error != null) {
                // Need _id of existing user record so this call must come
                // after `Accounts.createUser` or `Accounts.onCreate`
                //Meteor.users.update({_id: Meteor.userId()}, {$set: {'emails.0.verified': true}});
                Roles.addUsersToRoles( Meteor.userId(), user.roles);
            }
        });
    };

The idea is that everytime i need a user i create a user and attach the roles needed. This seems to work. But I am getting this error / warning in the console.
insert failed: MongoError: E11000 duplicate key error index: mocha-web.roles.$name_1 dup key: { : "athlete" }
This error is not showing up when I run the same 'code' in my /client og /server directories.

Furthermore i have for the purpose of test inserted this in my /server
Meteor.users.allow({
update: function (userId, user) {
return true;
}
});
Because otherwise i'm getting a Access denied from roles.js when updating the user. And I can't seem figure out why, since the Meteor documentation states that when creating a user with Accounts.createUser the users is also logged in. Any idea why i can't update the user object without a general update-allow for the Meteor.users?

Thanks in advance

@alanning
Copy link
Contributor

alanning commented Aug 9, 2014

Hi Henrik, this should probably be posted to one of the velocity test framework repo's since it only happens when testing. But we can try to debug it here for now.

This error, insert failed: MongoError: E11000 duplicate key error index: mocha-web.roles.$name_1 dup key: { : "athlete" } has 'mocha-web' as the database. Is that expected? If not then I'd guess its some kind of a problem with the mirroring that velocity is doing.

For the second issue, if you put together a public reproduction up on github I'll help debug.

@hkirk
Copy link
Author

hkirk commented Aug 11, 2014

I'll try creating a public repository with the same error.

@alanning alanning closed this as completed Oct 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants