From 22e929e439a6f071154a2f41490c9c99bcd0d2a6 Mon Sep 17 00:00:00 2001 From: Raymond Feng Date: Fri, 16 May 2014 13:46:58 -0700 Subject: [PATCH 1/2] Fix credentials/challenges types Associated identities and credentials are now captured by models in loopback-component-passport. These two properties will be removed in 2.x. --- lib/models/user.js | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/lib/models/user.js b/lib/models/user.js index 877eb36b..e1518bd4 100644 --- a/lib/models/user.js +++ b/lib/models/user.js @@ -26,22 +26,11 @@ var properties = { realm: {type: String}, username: {type: String}, 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}, emailVerified: Boolean, 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, created: Date, lastUpdated: Date From 76b6dc10d9b76e644d200de2d024bbea318ba61a Mon Sep 17 00:00:00 2001 From: Raymond Feng Date: Tue, 15 Jul 2014 08:20:47 -0700 Subject: [PATCH 2/2] Add a test case for credentials/challenges --- test/user.test.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/user.test.js b/test/user.test.js index e0c53e32..1329f510 100644 --- a/test/user.test.js +++ b/test/user.test.js @@ -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) { User.create({password: '123'}, function (err) { assert(err);