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 can I remove all sessions from one user? #201
Comments
There is no concept of user in Example: db.sessions.remove({ 'session.user': VALUE }); |
Thank you! |
You will need to set |
How do you set the property "user" in the sessions? I'm using mongoose 4.x and node 0.10. I'm trying to set it like this : |
I'm also interested by this feature. What is the best way to access to the MongoDriver without instantiating a new one ? |
@jmcollin78: The @Madhu94: You can't set any default attribute in the constructor. |
@jdesboeufs Many thank's for your answer. For those who can be interested, I've implemented this feature with ouathtoken and passport with this piece of code:
Of course you will need to adapt this to your case. JM. |
Sorry for the late drive-by question, but what happens if there is a cluster? If there are other workers in the cluster that are using the session, are they using an in-memory cached version of the session or does it actually hit the mongodb every time? Where's the caching handled? I'm worried that removing the session documents from the mongodb won't actually invalidate the session for other nodes in the cluster due to caching. Do you need redis or something to tell the other workers in the cluster to invalidate their session cache? Is there even a session cache? This seems like it can't work without something like redis. Does it really work just to delete the session documents? Feel free to tell me otherwise. |
@wyckster did you end up finding a solution to this problem? |
If you are reading this, you might wonder what is the solution if you have One easy way is to have separate collection of active sessions with:
then, with every new login, you will add a record to this collection. Then, deleting all sessions from a single user is easy. |
Question:
How can I remove all sessions from one user?
Thanks!
The text was updated successfully, but these errors were encountered: