Fantastic job! We have covered a lot regarding authentication and Passport.js. In the workspace, we’ve provided you a sandbox with authentication implemented in case you want further experiment with the library.
Creating the authentication process from scratch can be lengthy and cumbersome, but thanks to Passport.js we can facilitate the login process by integrating it in an Express application.
In this lesson we covered:
What strategies are and how to use a local strategy to authenticate users with a username and password.
How to configure the local strategy as middleware in
How to manage persistent logins using
How to use the
passport.authenticate()middleware for login endpoints.
How to log out a user through the
logout()function that’s exposed in the request object.
Passport.js has a vast number of other built-in functions that allow us to customize the authentication process even further. We’ve looked into authenticating users with a username and password, but we’re also provided with a number of other strategies, from logging in users with Facebook, Twitter, Google, or even using JSON Web Tokens! If you’d like to explore what other features are available, feel free to refer to the main documentation.