Skip to content

The Complete Node.js Course: Authentication and Authorization

Introduction

Creating the User Model

Registering Users

Using Lodash

Hashing Passwords

Authenticating Users

Testing the Authentication

JSON Web Tokens

Generating Authentication Tokens

Storing Secrets in Environment Variables

Setting Response Headers

Encapsulating Logic in Mongoose Models

Authorization Middleware

Protecting Routes

Getting the Current User

Logging Out Users

Role-based Authorization

Testing the Authorization

Recap