diff --git a/doc/7/controllers/security/create-user/snippets/create-user.test.yml b/doc/7/controllers/security/create-user/snippets/create-user.test.yml index 342c48fd6..d335f9348 100644 --- a/doc/7/controllers/security/create-user/snippets/create-user.test.yml +++ b/doc/7/controllers/security/create-user/snippets/create-user.test.yml @@ -6,5 +6,5 @@ template: default expected: - "User {" - "_id: 'jdoe'," - - "content: {" + - "_source: {" - "profileIds: \\[ \\'default\\' \\]," diff --git a/doc/7/core-classes/user/properties/index.md b/doc/7/core-classes/user/properties/index.md index 10f509314..17f674890 100644 --- a/doc/7/core-classes/user/properties/index.md +++ b/doc/7/core-classes/user/properties/index.md @@ -9,16 +9,17 @@ order: 10 # Properties -| Property | Type | Description | -|--- |--- |--- | -| `_id` |
string
| User ID (kuid) | -| `content` |
object
| User internal content | +| Property | Type | Description | +|-----------|-------------------|---------------------------------------------------------------| +| `_id` |
string
| User ID (kuid) | +| `_source` |
object
| User internal content | +| `content` |
object
| User internal content | -### content +### _source -The `content` property is an object containing, alongside custom defined values, the following generic properties: +The `_source` property is an object containing, alongside custom defined values, the following generic properties: -| Property | Type | Description | -|--- |--- |--- | -| `profileIds` |
string[]
| Profiles IDs for this user | -| `_kuzzle_info` |
object
| [Kuzzle metadata](/core/2/guides/main-concepts/data-storage#kuzzle-metadata) | +| Property | Type | Description | +|----------------|---------------------|------------------------------------------------------------------------------| +| `profileIds` |
string[]
| Profiles IDs for this user | +| `_kuzzle_info` |
object
| [Kuzzle metadata](/core/2/guides/main-concepts/data-storage#kuzzle-metadata) | diff --git a/src/core/security/User.ts b/src/core/security/User.ts index 82db5728d..f6ed3719c 100644 --- a/src/core/security/User.ts +++ b/src/core/security/User.ts @@ -6,10 +6,20 @@ export class User { * Kuid (Kuzzle unique ID) */ public _id: string; + + /** + * User content + */ + public _source: JSONObject; + /** - * Custom content + * User content + * + * @deprecated */ - public content: JSONObject; + get content (): JSONObject { + return this._source; + } private _kuzzle: any; @@ -24,7 +34,7 @@ export class User { }); this._id = _id; - this.content = content; + this._source = content; } private get kuzzle () { @@ -35,7 +45,7 @@ export class User { * Array of profile IDs */ get profileIds (): Array { - return this.content.profileIds || []; + return this._source.profileIds || []; } /** diff --git a/test/core/security/user.test.js b/test/core/security/user.test.js index 57054e5b5..cdb7c5369 100644 --- a/test/core/security/user.test.js +++ b/test/core/security/user.test.js @@ -41,4 +41,18 @@ describe('User', () => { }); }); }); + + describe('#_source', () => { + it('should return the user custom content', () => { + user = new User({}, 'foobar', { email: 'foobar@goo.com' }); + + should(user._source).be.eql({ email: 'foobar@goo.com' }); + }); + + it('should keep accessors to deprecated "content" getter', () => { + user = new User({}, 'foobar', { email: 'foobar@goo.com' }); + + should(user.content).be.eql({ email: 'foobar@goo.com' }); + }); + }); }); \ No newline at end of file