-
-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to authenticate #30
Comments
You don't have access to the const mongoose = require('mongoose');
// Basic usage
mongoose.connect(connectionOptions);
server({ session: false }, server.utils.modern(session({
store: new MongoStore({
mongooseConnection: mongoose.connection
})
}))); You can use any express middleware by wrapping it with |
Or even easier, you could use the native server store option: const mongoose = require('mongoose');
mongoose.connect(connectionOptions);
// See options docs
const options = {
session: {
store: new MongoStore({
mongooseConnection: mongoose.connection
})
}
};
server(options, ...); |
@franckstifler please let me know if that answers your question |
@franciscop Let me get to my computer giving you a feedback in about 30min. I can make use of flash messages too right? |
The problem persists. Using connect-mongo documentation this is how I have to require the modules: |
You are totally right, for this version you don't have access to |
https://github.com/franckstifler/CheckAM/blob/master/index.js sorry for the late reply had to adjust some things before making a push. That is a project I am building powered by server.js. |
Did you try the snippet above? const mongoose = require('mongoose');
mongoose.connect(connectionOptions);
// See options docs
const options = {
session: {
store: new MongoStore({
mongooseConnection: mongoose.connection
})
}
};
server(options, ...); Seems like you are using mongoose already from your project so you should be able to do that. You even have that in line 23 (but it is commented): store: new MongoStore({ mongooseConnection: mongoose.connection }) Does that work? The line 4 in that situation should be like this: const MongoStore = require('connect-mongo'); // NO (server) |
In deed I tried. The problem is actually in line 4 because you must init connect-mongo with a session. |
You can skip it in line 4 and just load it without const MongoStore = require('connect-mongo'); // NO (server) Edit: that would be the same as this example, where they are inconveniently missing the line I wrote above (or so I think): https://github.com/jdesboeufs/connect-mongo#re-use-a-mongoose-connection |
I believe I am struggling with the exact same issues wrt |
In deed I loaded without session but it wont work, complaining that it needs a store. |
What about something like this? I think it should work properly now: const server = require('server');
// "server.session" contains the result of require('express-session');
// so you can inject it wherever it's needed
// Not to be confused with a current session
const MongoStore = require('connect-mongo')(server.session);
const store = new MongoStore(options);
server({ session: { store } }, ...); It should be available in the latest |
Sorry for the delay. Testing right a way and giving you a feedback. |
Good it works like charm now. |
Glad to hear! And thanks for the feedback 😇 |
Sure I can continue to work on my project. Think of creating a tutorial for that in the docs. I think it is very important. |
I did add it to the documentation for session stores, but I should add it to the Sessions in Production tutorial as well. |
I am curious on how to authenticate using server. I don't see how to configure my session store to be mongoDB using
connect-mongo
. A tutorial on how to this will be really helpful.The text was updated successfully, but these errors were encountered: