| Start |
|---|
| Local authentication The passport-local module is used to implement a local authentication. This module lets you authenticate using a username and password in your Node.js applications. Registering the user : Logging in the user : Creating routes : |
| Getting started Passport must be initialized using Note that |
| Facebook authentication The passport-facebook module is used to implement a Facebook authentication. In this example, if the user does not exist on sign-in, he is created. Implementing strategy : Creating routes : |
| Simple Username-Password Authentication In your routes/index.js Here |
| Google Passport authentication We have simple module available in npm for goggle authetication name passport-google-oauth20 Consider the following example In this example have created a folder namely config having the passport.js and google.js file in the root directory. In your app.js include the following // other code to initailize the server , error handle In the passport.js file in the config folder include the following code In the google.js file in the same config folder include following Here in this example, if user is not in DB then creating a new user in DB for local reference using the field name googleId in user model. RemarksPassword must always be hashed. A simple way to secure passwords using NodeJS would be to use bcrypt-nodejs module. |
Read Article
https://develop.horje.com/learn/1434/reference