In node.js authentication and login could be a difficult task but there are some modules available in node that makes it easier for a node developer. One of them is Passport.
Passport is a middleware that allows us to authenticate using username and password called as local strategy. Apart from local strategy, passport has a set of strategies for authentication like facebook, twitter and so on, based on our requirement we can use any of them.
In this particular blog i am going to use local authentication.
First of all i am going to create an application using express generator:
Now we will install passport and passport-local Node modules using the below commands:
npm install passport
npm install passport-local
Once installation is done we create a login form, so create a file view/login.html: