Skip to content

Commit 0c6199b

Browse files
author
ballinette
committed
Fix #91: format correctly roles within profile definition
1 parent a02b5e0 commit 0c6199b

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/security/kuzzleSecurity.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,15 @@ KuzzleSecurity.prototype.getProfile = function (id, options, cb) {
289289

290290
if (!hydrate) {
291291
response.result._source.roles = response.result._source.roles.map(function (role) {
292-
return role._id;
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;
293301
});
294302
}
295303

test/security/kuzzleSecurity/profilesMethods.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ describe('KuzzleSecurity profiles methods', function () {
7878
should(res.content.roles).not.be.empty();
7979

8080
res.content.roles.forEach(function (role) {
81-
should(role).be.a.String();
81+
should(role._id).not.be.empty().and.be.a.String();
8282
});
8383
done();
8484
}));

0 commit comments

Comments
 (0)