Comments (14)
Can you create a self-contained gist, so that I can re-create this issue independently on my machine?
--Brian
from mongoose-auth.
Sorry, but this was my fault. I was able to get it to work just fine. Thanks for getting back to me so quickly, though!
from mongoose-auth.
@geetarista , I'm having the same problem, could you please explain what the issue was. thanks in advance.
from mongoose-auth.
@christopherdebeer I honestly don't remember exactly what it was, but I remember that it was something I missed in the documentation, which is why I didn't post it here.
from mongoose-auth.
I have the same issue, did you remember what is missing?
from mongoose-auth.
@christopherdebeer @dmmalam Can you share gists of your code here, so I can help you out?
from mongoose-auth.
This was solved by initializing mongo BEFORE configuring express
from mongoose-auth.
@dmmalam thanks, I ended-up just using every-auth and mongoose (not mongoose-auth), but i'll look back into it.
from mongoose-auth.
I have spent a bunch of time trying to solve the problem. At last I looked into the mongoose-auth source.
The reason of such a behavior is that the module exports a function (plugin
). Extending the module with everyauth methods (middleware
and helpExpress
) is performed INSIDE of the exported function (see source — https://github.com/bnoguchi/mongoose-auth/blob/master/index.js#L78)
So the only obvious way to use those methods is to invoke a mongoose-auth's exported function at least once.
Let me show (assuming server
is express or connect server):
The following WILL work:
var mongoose = require('mongoose'),
Schema = mongoose.Schema,
mongooseAuth = require('mongoose-auth');
...
var UserSchema = new Schema({});
UserSchema.plugin(mongooseAuth, {
facebook: true
});
...
server.use(mongoose.middleware());
The following WILL NOT work:
var mongoose = require('mongoose'),
Schema = mongoose.Schema,
mongooseAuth = require('mongoose-auth');
...
server.use(mongoose.middleware());
...
var UserSchema = new Schema({});
UserSchema.plugin(mongooseAuth, {
facebook: true
});
from mongoose-auth.
@tsabolov any progress, or any info about whether a fix is coming?
from mongoose-auth.
@paulshapiro As I am not the author of this project, I absolutely have no idea about when it will be fixed.
For myself I have fixed it the following way:
At the very end of the file /index.js there are such a lines:
// Delegate middleware method to
// everyauth's middleware method
exports.middleware = everyauth.middleware.bind(everyauth);
// Delegate helpExpress method to everyauth.
// Adds dynamic helpers such as loggedIn,
// accessible from the views
exports.helpExpress = everyauth.helpExpress.bind(everyauth);
};
To make the module work with just requiring it move exporting of function out of the function just like below:
};
// Delegate middleware method to
// everyauth's middleware method
exports.middleware = everyauth.middleware.bind(everyauth);
// Delegate helpExpress method to everyauth.
// Adds dynamic helpers such as loggedIn,
// accessible from the views
exports.helpExpress = everyauth.helpExpress.bind(everyauth); /* NOW THIS IS THE LAST LINE IN THE index.js */
from mongoose-auth.
@tsabolov, ic, thanks. will keep this in mind.
from mongoose-auth.
@tsabolov Thanks for your comment! I adjusted the schema placement, and it ran like a charm.
from mongoose-auth.
@tsabolov, npm package 0.0.11 which is the current master version, is working in my case without updating the changes your mention.
I could get all working well when i follow the configuration steps on the correct order.
from mongoose-auth.
Related Issues (20)
- Doesn't install out-of-the-box on Windows (without cygwin) HOT 3
- Is this project still being maintained? HOT 8
- problem installing mongoose-auth on Mac OSX HOT 3
- routing with password authentication?
- Cannot find module 'bcrypt' in nodejs application ? HOT 1
- How do I fix this? getAccessToken of `twitter` module timed out.
- mongooseauth cant install in Windows npm HOT 1
- Node 0.8.0, OSX, bcrypt installs but won't load, wrong architecture HOT 2
- Not able to register new user HOT 1
- Examples on the site incompatible with the latest version of express
- Error with everyauth after 0.3 version update HOT 8
- "everyauth is not defined" error when using view helpers HOT 1
- Installation fails on Linux64 HOT 2
- Where I can found the createWithFB method described on the README.
- Broken out of the box.
- Workin example in Rails
- Error on running example
- Error running example HOT 3
- Don't create a session after registering HOT 2
- problem with loginWith
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mongoose-auth.