Skip to content

Commit 31df206

Browse files
Merge pull request #229 from kuzzleio/create-user-w-null-id
Allow creating a user without specifying the id
2 parents ef1ba25 + 0c74143 commit 31df206

File tree

2 files changed

+0
-18
lines changed

2 files changed

+0
-18
lines changed

src/security/Security.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -562,10 +562,6 @@ Security.prototype.createUser = function (id, content, options, cb) {
562562
self = this,
563563
data = {_id: id, body: content};
564564

565-
if (!id || typeof id !== 'string') {
566-
throw new Error('Security.createUser: cannot create a user without a user ID');
567-
}
568-
569565
if (!cb && typeof options === 'function') {
570566
cb = options;
571567
options = null;
@@ -619,10 +615,6 @@ Security.prototype.createRestrictedUser = function (id, content, options, cb) {
619615
self = this,
620616
data = {_id: id, body: content};
621617

622-
if (!id || typeof id !== 'string') {
623-
throw new Error('Security.createRestrictedUser: cannot create a user without a user ID');
624-
}
625-
626618
if (content.profileIds) {
627619
throw new Error('Security.createRestrictedUser: cannot provide profileIds');
628620
}

test/security/kuzzleSecurity/userMethods.test.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,6 @@ describe('Security user methods', function () {
160160
should(kuzzle.query).calledWith(expectedQuery, {_id: 'foobar', body: content}, null, undefined);
161161
});
162162

163-
it('should throw an error if no id provided', function () {
164-
should(function () { kuzzle.security.createUser(null); }).throw(Error);
165-
should(kuzzle.query).not.be.called();
166-
});
167-
168163
it('should call the callback with an error if one occurs', function (done) {
169164
this.timeout(50);
170165

@@ -209,11 +204,6 @@ describe('Security user methods', function () {
209204
should(kuzzle.query).calledWith(expectedQuery, {_id: 'foobar', body: content}, null, undefined);
210205
});
211206

212-
it('should throw an error if no id provided', function () {
213-
should(function () { kuzzle.security.createRestrictedUser(null); }).throw(Error);
214-
should(kuzzle.query).not.be.called();
215-
});
216-
217207
it('should throw an error if profileIds is provided', function () {
218208
should(function () { kuzzle.security.createRestrictedUser('foobar', {profileIds: ['someProfile']}); }).throw(Error);
219209
should(kuzzle.query).not.be.called();

0 commit comments

Comments
 (0)