mongoose-auth icon indicating copy to clipboard operation
mongoose-auth copied to clipboard

fix for everyauth3

Open cbou opened this issue 12 years ago • 5 comments

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.

cbou avatar Aug 14 '12 08:08 cbou

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

lfalvarez avatar Aug 30 '12 02:08 lfalvarez

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.

nirarazi avatar Sep 11 '12 12:09 nirarazi

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

simpleshadow avatar Jan 05 '13 10:01 simpleshadow

Confirmed, it works. Thanks for sharing!

paolomainardi avatar Jan 23 '13 00:01 paolomainardi

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

hackingbeauty avatar Dec 01 '13 05:12 hackingbeauty