Home > Blockchain >  Multiple device login using jwt
Multiple device login using jwt

Time:08-07

I am building an application and I want users to be able to log in from multiple devices without logging out of other devices.

How should I implement this functionality?

I am using Jwt token for authentication and MySQL database for storing user details

CodePudding user response:

Here is a boilerplate on how to do that.

https://github.com/aichbauer/express-rest-api-boilerplate

CodePudding user response:

JWT is primarily use for performing stateless authentication i.e. you don't need to perform lookup in the database for validating the token. Also, Token contain some user details which are enough for identifying the owner of the token so you don't need to store the token in the database.

I want users to be able to log in from multiple devices without logging out of other devices.

You can issue multiple tokens to the same user requesting from different platforms. These token will have different expiration time, so user remain log-in irrespective of the platform they would try to use and log out process will entirely depend upon the expiration time of the token.

  • Related