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

Modifying user roles #114

Closed
jobidon opened this issue Aug 19, 2016 · 0 comments · Fixed by #178
Closed

Modifying user roles #114

jobidon opened this issue Aug 19, 2016 · 0 comments · Fixed by #178

Comments

@jobidon
Copy link

jobidon commented Aug 19, 2016

I tried the following:

function test() {
    var that=this;
    //currently logged in as a user with role = '_admin'
    this.DB.signup("batman", "pwd", {metadata: {roles: ['aaa','bbb']}})
            .then(function(r) {
                console.log("Create user: "+r.ok);
                return that.DB.putUser("batman", {metadata: {roles: ['ccc']}})
            }).then(function(r) {
                console.log("Modified user: "+r.ok);        //Modified user: true
                return that.DB.getUser("batman");
            }).then(function(r) {
                console.log("Resulting roles: "+r.roles);   //Resulting roles: ccc,bbb
                return r;
            }).catch(console.log);
    }
}

I was expecting the resulting log to indicate that the resulting role was 'ccc', however, it looks like the first element of the array was replaced by the first element of the new array, but the rest of the array remained unchanged.
How do I go about removing the rest of the roles other than with a: {role: ["","",......]}?

As a side note, how do I delete a user? Is there a deleteUser(name, [callback]) or equivalent?
Thanks for your input!

ptitjes added a commit to ptitjes/pouchdb-authentication that referenced this issue Nov 14, 2017
Closes pouchdb-community#114

Roles can now be modified via putUser by passing ops.roles.
ptitjes added a commit to ptitjes/pouchdb-authentication that referenced this issue Nov 17, 2017
Closes pouchdb-community#114

Roles can now be modified via putUser by passing ops.roles.
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

Successfully merging a pull request may close this issue.

1 participant