Skip to content

Commit 817e76e

Browse files
author
David Cheung
committed
Remove unused UserModel properties
- credentials - challenges - status - created - lastUpdated
1 parent 363bc4d commit 817e76e

4 files changed

Lines changed: 27 additions & 32 deletions

File tree

3.0-RELEASE-NOTES.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,29 @@ PersistedModel.handleChangeError. This method can be customized on a per-model b
7373
provide different error handling.
7474

7575
Please see [related code change](https://github.com/strongloop/loopback/pull/2308) here.
76+
77+
78+
## remove unused user properties
79+
The following properties are removed from the built-in User model in 3.0:
80+
- credentials
81+
- challenges
82+
- status
83+
- created
84+
- lastUpdated
85+
86+
Developers that are relying on these properties, can redefine them in `user.json` or equivalent model.json as follow:
87+
```json
88+
{
89+
"name": "MyUser",
90+
"base": "User",
91+
"properties": {
92+
"credentials": { "type": "object" },
93+
"challenges": { "type": "object" },
94+
"status": "string",
95+
"created": "date",
96+
"lastUpdated": "date"
97+
}
98+
}
99+
```
100+
101+
Please see [Related code change](https://github.com/strongloop/loopback/pull/2299) here.

common/models/user.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@ var debug = require('debug')('loopback:user');
5353
* @property {Boolean} emailVerified Set when a user's email has been verified via `confirm()`.
5454
* @property {String} verificationToken Set when `verify()` is called.
5555
* @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.
56-
* @property {Date} created The property is not used by LoopBack, you are free to use it for your own purposes.
57-
* @property {Date} lastUpdated The property is not used by LoopBack, you are free to use it for your own purposes.
58-
* @property {String} status The property is not used by LoopBack, you are free to use it for your own purposes.
5956
* @property {Object} settings Extends the `Model.settings` object.
6057
* @property {Boolean} settings.emailVerificationRequired Require the email verification
6158
* process before allowing a login.

common/models/user.json

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,12 @@
1111
"type": "string",
1212
"required": true
1313
},
14-
"credentials": {
15-
"type": "object",
16-
"deprecated": true
17-
},
18-
"challenges": {
19-
"type": "object",
20-
"deprecated": true
21-
},
2214
"email": {
2315
"type": "string",
2416
"required": true
2517
},
2618
"emailVerified": "boolean",
27-
"verificationToken": "string",
28-
"status": "string",
29-
"created": "date",
30-
"lastUpdated": "date"
19+
"verificationToken": "string"
3120
},
3221
"options": {
3322
"caseSensitiveEmail": true

test/user.test.js

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -110,23 +110,6 @@ describe('User', function() {
110110
});
111111
});
112112

113-
it('credentials/challenges are object types', function(done) {
114-
User.create({ email: 'f1@b.com', password: 'bar1',
115-
credentials: { cert: 'xxxxx', key: '111' },
116-
challenges: { x: 'X', a: 1 },
117-
}, function(err, user) {
118-
assert(!err);
119-
User.findById(user.id, function(err, user) {
120-
assert(user.id);
121-
assert(user.email);
122-
assert.deepEqual(user.credentials, { cert: 'xxxxx', key: '111' });
123-
assert.deepEqual(user.challenges, { x: 'X', a: 1 });
124-
125-
done();
126-
});
127-
});
128-
});
129-
130113
it('Email is required', function(done) {
131114
User.create({ password: '123' }, function(err) {
132115
assert(err);

0 commit comments

Comments
 (0)