bnoguchi/everyauth — Issue #157: Uncaught exception using 'promise.fail(err)' with node@0.6.7 /express@2.5.4/mongoose@2.4.10 /everyauth@0.2.28
Author: uyjco0
Created: 2012-01-14 13:50:27+00:00
State: open

Hi,

I have the following situation: git://gist.github.com/1611430.git

When the user is in the database, the code is working perfectly, but when I'm testing for example with a non-existing user, I'm getting the following error:

*********************************************************************************************
starting step - displayLogin
...finished step
starting step - extractLoginPassword
...finished step
starting step - authenticate
Uncaught exception: Error: The user doesn't exist!Error: The user doesn't exist!
at [object Object].fail (/myApp/node_modules/everyauth/lib/promise.js:50:15)
at Promise. (/myApp/lib/db/models.js:62:28)
at Promise. (/myApp/node_modules/mongoose/lib/promise.js:120:8)
at Promise. (events.js:67:17)
at Promise.emit (/myApp/node_modules/mongoose/lib/promise.js:59:38)
at Promise.complete (/myApp/node_modules/mongoose/lib/promise.js:70:20)
at /myApp/node_modules/mongoose/lib/query.js:889:30
at /myApp/node_modules/mongoose/lib/utils.js:394:16
at /myApp/node_modules/mongoose/node_modules/mongodb/lib/mongodb/collection.js:907:5
at /myApp/node_modules/mongoose/node_modules/mongodb/lib/mongodb/cursor.js:135:9
*********************************************************************************************

Related to that is that the documentation suggests to use for the module 'password', the following:

****************************
// Example 2 - Async Example
// var promise = this.Promise()
// YourUserModel.find({ login: login}, function (err, user) {
// if (err) return promise.fulfill([err]);
// promise.fulfill(user);
// }
// return promise;
****************************

But, using ' if (err) return promise.fulfill([err]);' instead of promise.fail('err') let the local 'everyauth.loggedIn' in true, thus creating the session, despite the user doesn't exist.

Any idea to resolve it?

Thanks in advance!