kuzzleio / kuzzle

Open-source Back-end, self-hostable & ready to use - Real-time, storage, advanced search - Web, Apps, Mobile, IoT -
https://kuzzle.io
Apache License 2.0
1.44k stars 124 forks source link

Response when deleting user is not returning id of deleted object #215

Closed mbmadaj closed 8 years ago

mbmadaj commented 8 years ago

When I deleteUser I do no get result with id of deleted object.

Easily reproducible, with JS SDK as example:

kuzzle
  .security
  .createUser('myuser', userContent, options, function(error, response) {
    // result is a KuzzleUser object
    console.log(error)
    console.log(response)
  });
kuzzle
  .security
  .deleteUser('myuser', function(error, result) {
    console.log(error) // undefined - which is expected
    console.log(result) // undefined - which is not expected
  });

When I call directly deleteUser with query

kuzzle.query({controller: 'security', action: 'deleteUser'}, {"_id": 'myuser'}, function (err, res) {
  console.log(err)
  console.log(res) // no key _id under result (and no value, the reason SDK returns undefined)
});

Probable reason, in response empty {} is returned https://github.com/kuzzleio/kuzzle/blob/ce5415b998537ac85975d83d398a701373e8b40a/lib/api/controllers/securityController.js#L333

mbmadaj commented 8 years ago

The deletion process works as expected, when I call for 2nd time deletion of just deleted user I receive error that user was not found.

scottinet commented 8 years ago

Got it.

We also have multiple bugs with other security routes, like updateRole, updateProfile and updateUser, as they don't provide the updated document in the response.

Check out the securityRoutesFixes branch. Implementation is finished, I'm now working on the unit tests.

scottinet commented 8 years ago

The pull request fixing this issue has been merged on the develop branch and the master will be updated soon.