@@ -252,9 +252,6 @@ KuzzleSecurity.prototype.roleFactory = function(id, content) {
252252/** 
253253 * Get a specific profile from kuzzle 
254254 * 
255-  * Takes an optional argument object with the following property: 
256-  *    - hydrate (boolean, default: true): 
257-  *         if is set to false, return a list id in role instead of KuzzleRole. 
258255 * 
259256 * @param  {string } id 
260257 * @param  {object } [options] - (optional) arguments 
@@ -263,21 +260,18 @@ KuzzleSecurity.prototype.roleFactory = function(id, content) {
263260KuzzleSecurity . prototype . getProfile  =  function  ( id ,  options ,  cb )  { 
264261  var 
265262    data , 
266-     self  =  this , 
267-     hydrate  =  true ; 
268- 
269-   if  ( ! id  ||  typeof  id  !==  'string' )  { 
270-     throw  new  Error ( 'Id parameter is mandatory for getProfile function' ) ; 
271-   } 
263+     self  =  this ; 
272264
273265  if  ( ! cb  &&  typeof  options  ===  'function' )  { 
274266    cb  =  options ; 
275267    options  =  null ; 
276268  } 
277-   else  if  ( options . hydrate  !==  undefined )  { 
278-     hydrate  =  options . hydrate ; 
269+ 
270+   if  ( ! id  ||  typeof  id  !==  'string' )  { 
271+     throw  new  Error ( 'Id parameter is mandatory for getProfile function' ) ; 
279272  } 
280273
274+ 
281275  data  =  { _id : id } ; 
282276
283277  self . kuzzle . callbackRequired ( 'KuzzleSecurity.getProfile' ,  cb ) ; 
@@ -287,31 +281,13 @@ KuzzleSecurity.prototype.getProfile = function (id, options, cb) {
287281      return  cb ( error ) ; 
288282    } 
289283
290-     if  ( ! hydrate )  { 
291-       response . result . _source . roles  =  response . result . _source . roles . map ( function  ( role )  { 
292-         var  formattedRole  =  { _id : role . _id } ; 
293-         if  ( role . _source . restrictedTo  !==  undefined )  { 
294-           formattedRole . restrictedTo  =  role . _source . restrictedTo ; 
295-         } 
296-         if  ( role . _source . allowInternalIndex  !==  undefined )  { 
297-           formattedRole . allowInternalIndex  =  role . _source . allowInternalIndex ; 
298-         } 
299- 
300-         return  formattedRole ; 
301-       } ) ; 
302-     } 
303- 
304284    cb ( null ,  new  KuzzleProfile ( self ,  response . result . _id ,  response . result . _source ) ) ; 
305285  } ) ; 
306286} ; 
307287
308288/** 
309289 * Executes a search on profiles according to a filter 
310290 * 
311-  * Takes an optional argument object with the following property: 
312-  *    - hydrate (boolean, default: true): 
313-  *         if is set to false, return a list id in role instead of KuzzleRole. 
314-  *         Because hydrate need to fetch all related KuzzleRole object, leave hydrate to true will have a performance cost 
315291 * 
316292 * /!\ There is a small delay between profile creation and their existence in our persistent search layer, 
317293 * usually a couple of seconds. 
@@ -325,15 +301,10 @@ KuzzleSecurity.prototype.searchProfiles = function (filters, options, cb) {
325301  var 
326302    self  =  this ; 
327303
328-   filters . hydrate  =  true ; 
329- 
330304  if  ( ! cb  &&  typeof  options  ===  'function' )  { 
331305    cb  =  options ; 
332306    options  =  null ; 
333307  } 
334-   else  if  ( options . hydrate  !==  undefined )  { 
335-     filters . hydrate  =  options . hydrate ; 
336-   } 
337308
338309  self . kuzzle . callbackRequired ( 'KuzzleSecurity.searchProfiles' ,  cb ) ; 
339310
@@ -439,13 +410,7 @@ KuzzleSecurity.prototype.updateProfile = function (id, content, options, cb) {
439410      } 
440411
441412      Object . keys ( res . result . _source ) . forEach ( function  ( property )  { 
442-         if  ( property  !==  'roles' )  { 
443-           updatedContent [ property ]  =  res . result . _source [ property ] ; 
444-         } 
445-       } ) ; 
446- 
447-       updatedContent . roles  =  res . result . _source . roles . map ( function  ( role )  { 
448-         return  role . _id ; 
413+         updatedContent [ property ]  =  res . result . _source [ property ] ; 
449414      } ) ; 
450415
451416      cb ( null ,  new  KuzzleProfile ( self ,  res . result . _id ,  updatedContent ) ) ; 
@@ -503,19 +468,14 @@ KuzzleSecurity.prototype.profileFactory = function(id, content) {
503468/** 
504469 * Get a specific user from kuzzle using its unique ID 
505470 * 
506-  * Takes an optional argument object with the following property: 
507-  *    - hydrate (boolean, default: true): 
508-  *         if is set to false, return a list id in role instead of KuzzleRole. 
509-  * 
510471 * @param  {string } id 
511472 * @param  {object } [options] - (optional) arguments 
512473 * @param  {responseCallback } cb - returns Kuzzle's response 
513474 */ 
514475KuzzleSecurity . prototype . getUser  =  function  ( id ,  options ,  cb )  { 
515476  var 
516477    data , 
517-     self  =  this , 
518-     hydrate  =  true ; 
478+     self  =  this ; 
519479
520480  if  ( ! id  ||  typeof  id  !==  'string' )  { 
521481    throw  new  Error ( 'Id parameter is mandatory for getUser function' ) ; 
@@ -525,9 +485,6 @@ KuzzleSecurity.prototype.getUser = function (id, options, cb) {
525485    cb  =  options ; 
526486    options  =  null ; 
527487  } 
528-   else  if  ( options . hydrate  !==  undefined )  { 
529-     hydrate  =  options . hydrate ; 
530-   } 
531488
532489  data  =  { _id : id } ; 
533490
@@ -538,22 +495,13 @@ KuzzleSecurity.prototype.getUser = function (id, options, cb) {
538495      return  cb ( err ) ; 
539496    } 
540497
541-     if  ( ! hydrate )  { 
542-       response . result . _source . profile  =  response . result . _source . profile . _id ; 
543-     } 
544- 
545498    cb ( null ,  new  KuzzleUser ( self ,  response . result . _id ,  response . result . _source ) ) ; 
546499  } ) ; 
547500} ; 
548501
549502/** 
550503 * Executes a search on user according to a filter 
551504 * 
552-  * Takes an optional argument object with the following property: 
553-  *    - hydrate (boolean, default: true): 
554-  *         if is set to false, return a list id in role instead of KuzzleRole. 
555-  *         Because hydrate need to fetch all related KuzzleRole object, leave hydrate to true will have a performance cost 
556-  * 
557505 * /!\ There is a small delay between user creation and their existence in our persistent search layer, 
558506 * usually a couple of seconds. 
559507 * That means that a user that was just been created won’t be returned by this function. 
@@ -566,15 +514,10 @@ KuzzleSecurity.prototype.searchUsers = function (filters, options, cb) {
566514  var 
567515    self  =  this ; 
568516
569-   filters . hydrate  =  true ; 
570- 
571517  if  ( ! cb  &&  typeof  options  ===  'function' )  { 
572518    cb  =  options ; 
573519    options  =  null ; 
574520  } 
575-   else  if  ( options . hydrate  !==  undefined )  { 
576-     filters . hydrate  =  options . hydrate ; 
577-   } 
578521
579522  self . kuzzle . callbackRequired ( 'KuzzleSecurity.searchUsers' ,  cb ) ; 
580523
@@ -788,16 +731,17 @@ KuzzleSecurity.prototype.isActionAllowed = function(rights, controller, action,
788731/** 
789732 * Gets the rights array of a given user. 
790733 * 
791-  * @param   {string } userId The id of the user. 
792-  * @param   {function } cb   The callback containing the normalized array of rights. 
734+  * @param  {string } userId The id of the user. 
735+  * @param  {object } [options] - (optional) arguments 
736+  * @param  {function } cb   The callback containing the normalized array of rights. 
793737 */ 
794738KuzzleSecurity . prototype . getUserRights  =  function  ( userId ,  options ,  cb )  { 
795739  var 
796740    data  =  { _id : userId } , 
797741    self  =  this ; 
798742
799743  if  ( ! userId  ||  typeof  userId  !==  'string' )  { 
800-     throw  new  Error ( 'userId parameter is mandatory for isActionAllowed  function' ) ; 
744+     throw  new  Error ( 'userId parameter is mandatory for getUserRights  function' ) ; 
801745  } 
802746
803747  if  ( ! cb  &&  typeof  options  ===  'function' )  { 
0 commit comments