Coder Social home page Coder Social logo

Comments (14)

bnoguchi avatar bnoguchi commented on August 11, 2024

Can you create a self-contained gist, so that I can re-create this issue independently on my machine?

--Brian

from mongoose-auth.

geetarista avatar geetarista commented on August 11, 2024

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.

christopherdebeer avatar christopherdebeer commented on August 11, 2024

@geetarista , I'm having the same problem, could you please explain what the issue was. thanks in advance.

from mongoose-auth.

geetarista avatar geetarista commented on August 11, 2024

@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.

dmmalam avatar dmmalam commented on August 11, 2024

I have the same issue, did you remember what is missing?

from mongoose-auth.

bnoguchi avatar bnoguchi commented on August 11, 2024

@christopherdebeer @dmmalam Can you share gists of your code here, so I can help you out?

from mongoose-auth.

dmmalam avatar dmmalam commented on August 11, 2024

This was solved by initializing mongo BEFORE configuring express

from mongoose-auth.

christopherdebeer avatar christopherdebeer commented on August 11, 2024

@dmmalam thanks, I ended-up just using every-auth and mongoose (not mongoose-auth), but i'll look back into it.

from mongoose-auth.

tsabolov avatar tsabolov commented on August 11, 2024

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.

paulshapiro avatar paulshapiro commented on August 11, 2024

@tsabolov any progress, or any info about whether a fix is coming?

from mongoose-auth.

tsabolov avatar tsabolov commented on August 11, 2024

@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.

paulshapiro avatar paulshapiro commented on August 11, 2024

@tsabolov, ic, thanks. will keep this in mind.

from mongoose-auth.

willnathan avatar willnathan commented on August 11, 2024

@tsabolov Thanks for your comment! I adjusted the schema placement, and it ran like a charm.

from mongoose-auth.

ppcano avatar ppcano commented on August 11, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.