Skip to content

Commit

Permalink
Merge pull request #2299 from strongloop/removed-unused-user-properties
Browse files Browse the repository at this point in the history
[SEMVER-MAJOR] Removed unused user properties
  • Loading branch information
davidcheung committed May 10, 2016
2 parents 363bc4d + 817e76e commit a6f8c07
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 32 deletions.
26 changes: 26 additions & 0 deletions 3.0-RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,29 @@ PersistedModel.handleChangeError. This method can be customized on a per-model b
provide different error handling.

Please see [related code change](https://github.com/strongloop/loopback/pull/2308) here.


## remove unused user properties
The following properties are removed from the built-in User model in 3.0:
- credentials
- challenges
- status
- created
- lastUpdated

Developers that are relying on these properties, can redefine them in `user.json` or equivalent model.json as follow:
```json
{
"name": "MyUser",
"base": "User",
"properties": {
"credentials": { "type": "object" },
"challenges": { "type": "object" },
"status": "string",
"created": "date",
"lastUpdated": "date"
}
}
```

Please see [Related code change](https://github.com/strongloop/loopback/pull/2299) here.
3 changes: 0 additions & 3 deletions common/models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ var debug = require('debug')('loopback:user');
* @property {Boolean} emailVerified Set when a user's email has been verified via `confirm()`.
* @property {String} verificationToken Set when `verify()` is called.
* @property {String} realm The namespace the user belongs to. See [Partitioning users with realms](https://docs.strongloop.com/display/public/LB/Partitioning+users+with+realms) for details.
* @property {Date} created The property is not used by LoopBack, you are free to use it for your own purposes.
* @property {Date} lastUpdated The property is not used by LoopBack, you are free to use it for your own purposes.
* @property {String} status The property is not used by LoopBack, you are free to use it for your own purposes.
* @property {Object} settings Extends the `Model.settings` object.
* @property {Boolean} settings.emailVerificationRequired Require the email verification
* process before allowing a login.
Expand Down
13 changes: 1 addition & 12 deletions common/models/user.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,12 @@
"type": "string",
"required": true
},
"credentials": {
"type": "object",
"deprecated": true
},
"challenges": {
"type": "object",
"deprecated": true
},
"email": {
"type": "string",
"required": true
},
"emailVerified": "boolean",
"verificationToken": "string",
"status": "string",
"created": "date",
"lastUpdated": "date"
"verificationToken": "string"
},
"options": {
"caseSensitiveEmail": true
Expand Down
17 changes: 0 additions & 17 deletions test/user.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,23 +110,6 @@ describe('User', function() {
});
});

it('credentials/challenges are object types', function(done) {
User.create({ email: 'f1@b.com', password: 'bar1',
credentials: { cert: 'xxxxx', key: '111' },
challenges: { x: 'X', a: 1 },
}, function(err, user) {
assert(!err);
User.findById(user.id, function(err, user) {
assert(user.id);
assert(user.email);
assert.deepEqual(user.credentials, { cert: 'xxxxx', key: '111' });
assert.deepEqual(user.challenges, { x: 'X', a: 1 });

done();
});
});
});

it('Email is required', function(done) {
User.create({ password: '123' }, function(err) {
assert(err);
Expand Down

0 comments on commit a6f8c07

Please sign in to comment.