In order to build our own Token-based Authentication mechanism, we will need a token generator and a redis database to store the token with informations.
We need to generate an unique token when a user sign in. We create a route: POST /user/signin with {username,password} as body parameters. In this route, we check the credentials provided by the client with our user database (MongoDB, MySQL, or whatever database you are using). If the credentials are valid, we generate a token. In order to generate an unique token, we use the Crypto module.
Your new post is loading...