I am building a website based on Node.js.
The approach that I am following to ensure safety of the APIs is as follows:
- The user signs up with email and password.
- On successfull signup and login, the client receives a random generated token
- It stores the token in local storage and passes the token as header in all subsequent requests.
- For every subsequent request the server checks the token and validates the user.
- Once the user logs out,the token stored in client's local storage gets deleted
- The user gets a new token when he logs in again.
Is the above approach good enough?Please suggest better ways if any.
Also I have seen people using passport-local for authentication purpose. How can passport-local help in the above way of authentication?