Merge pull request #372 from strongloop/feature/cleanup-user-model

Feature/cleanup user model
This commit is contained in:
Raymond Feng 2014-07-15 08:21:49 -07:00
commit f4b1d00d4e
2 changed files with 18 additions and 13 deletions

View File

@ -26,22 +26,11 @@ var properties = {
realm: {type: String}, realm: {type: String},
username: {type: String}, username: {type: String},
password: {type: String, required: true}, password: {type: String, required: true},
credentials: Object, // deprecated, to be removed in 2.x
challenges: Object, // deprecated, to be removed in 2.x
email: {type: String, required: true}, email: {type: String, required: true},
emailVerified: Boolean, emailVerified: Boolean,
verificationToken: String, verificationToken: String,
credentials: [
'UserCredential' // User credentials, private or public, such as private/public keys, Kerberos tickets, oAuth tokens, facebook, google, github ids
],
challenges: [
'Challenge' // Security questions/answers
],
// https://en.wikipedia.org/wiki/Multi-factor_authentication
/*
factors: [
'AuthenticationFactor'
],
*/
status: String, status: String,
created: Date, created: Date,
lastUpdated: Date lastUpdated: Date

View File

@ -53,6 +53,22 @@ 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) { it('Email is required', function (done) {
User.create({password: '123'}, function (err) { User.create({password: '123'}, function (err) {
assert(err); assert(err);