Skip to content

fix for everyauth3#119

Open
cbou wants to merge 2 commits intobnoguchi:masterfrom
cbou:everymodule-fix
Open

fix for everyauth3#119
cbou wants to merge 2 commits intobnoguchi:masterfrom
cbou:everymodule-fix

Conversation

@cbou
Copy link

@cbou cbou commented Aug 14, 2012

This is a Fix for everyauth3.

Without it I get this error:

TypeError: Object #<Object> has no method 'User'
    at module.exports.findUserById (/home/charles/Repositories/Nuage/node_modules/mongoose-auth/lib/modules/everymodule/everyauth.js:7:10)
    at Object.fetchUserFromSession [as handle] (/home/charles/Repositories/Nuage/node_modules/mongoose-auth/node_modules/everyauth/index.js:99:13)
    at next (/home/charles/Repositories/Nuage/node_modules/mongoose-auth/node_modules/everyauth/node_modules/connect/lib/http.js:204:15)
    at Object.registerReqGettersAndMethods [as handle] (/home/charles/Repositories/Nuage/node_modules/mongoose-auth/node_modules/everyauth/index.js:75:9)
    at next (/home/charles/Repositories/Nuage/node_modules/mongoose-auth/node_modules/everyauth/node_modules/connect/lib/http.js:204:15)
    at HTTPServer.Server.handle (/home/charles/Repositories/Nuage/node_modules/mongoose-auth/node_modules/everyauth/node_modules/connect/lib/http.js:217:3)
    at Object.Server.use.handle (/home/charles/Repositories/Nuage/node_modules/express/node_modules/connect/lib/http.js:106:14)
    at next (/home/charles/Repositories/Nuage/node_modules/express/node_modules/connect/lib/http.js:204:15)
    at store.get.next (/home/charles/Repositories/Nuage/node_modules/express/node_modules/connect/lib/middleware/session.js:322:9)
    at /home/charles/Repositories/Nuage/node_modules/express/node_modules/connect/lib/middleware/session.js:341:9

I'm not sure if it makes sense but it works for me :p

Tests passed.

@lfalvarez
Copy link

I've use this fix and it works but it is expected to work in express3?

@nirarazi
Copy link

This should indeed work, but what if my model is not called 'User'? In my case I've named it 'Account'. There IS a method in the everyauth definition in mongoose-auth options that specifies a User() function that returns the model. The problem is that the 'this' object should refer to the everyauth object, but instead it refers to the window object.

The only fix I have in mind is to pass the model or everyauth as a parameter to the function call.

@simpleshadow
Copy link

I'm using this fix and it works for me.

@paolomainardi
Copy link

Confirmed, it works. Thanks for sharing!

@hackingbeauty
Copy link

The second commit that was listed (edc2bd2) worked for me. Why not pull this fix into the main branch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants