'How to prevent multiple sessions per user in nodejs and graphql?
before I explain my case, here's the tech stack I used in this app:
nodejs - express - graphql - jwt - mongoose - mongodb
so what I want to do, is to allow user to connect with one device at a time, for example if a user logged-in in device A, and then login in device B, I want to force logout him from device A, (I'm not using sessions btw, only jwt).
I have an idea to implement this:
- I want to use redis sessions, and store session-id and revoke it when same user is connecting in another device to reject upcoming requests from device A, I also want to use graphql-subscriptions and send a response to client to force logout the user, so I stop him from using the app, without waiting for the user to send a request first.
the app is a PWA, so will be there a problem using this method in mobile app ? and will graphql-subscriptions consume a lot of resources in the server to watch all the users at once, the estimated monthly users are 1000-5000. and what do you suggest as a good hosting specs, will 2gb ram and 1cpu enough for redis - express, graphql & graphql-subscriptions ?
I hope you can help me with this! thank you!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
