Skip to content

Commit 58d2f20

Browse files
author
Jeff
committed
finalize
1 parent 47e48ab commit 58d2f20

File tree

5 files changed

+19
-3
lines changed

5 files changed

+19
-3
lines changed

dist/kuzzle.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4696,8 +4696,12 @@ KuzzleUser.prototype.addProfile = function (profileId) {
46964696
throw new Error('Parameter "profileId" must be a string');
46974697
}
46984698

4699+
if (!this.content.profilesIds) {
4700+
this.content.profilesIds = [];
4701+
}
4702+
46994703
if (this.content.profilesIds.indexOf(profileId) === -1) {
4700-
this.content.profilesIds.push(profilesIds);
4704+
this.content.profilesIds.push(profileId);
47014705
}
47024706

47034707
return this;

dist/kuzzle.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/kuzzle.min.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/security/kuzzleUser.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ KuzzleUser.prototype.addProfile = function (profileId) {
6262
throw new Error('Parameter "profileId" must be a string');
6363
}
6464

65+
if (!this.content.profilesIds) {
66+
this.content.profilesIds = [];
67+
}
68+
6569
if (this.content.profilesIds.indexOf(profileId) === -1) {
6670
this.content.profilesIds.push(profileId);
6771
}

test/security/kuzzleUser/methods.test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,14 @@ describe('KuzzleUser methods', function () {
222222
done();
223223
});
224224

225+
it('should add the profile even if no profilesIds are currently set', function (done) {
226+
delete kuzzleUser.content.profilesIds;
227+
kuzzleUser.addProfile('profile1');
228+
229+
should(kuzzleUser.content.profilesIds).be.eql(['profile1']);
230+
done();
231+
});
232+
225233
});
226234

227235
describe('#serialize', function () {

0 commit comments

Comments
 (0)