The video for this lesson is currently being updated, please read the transcript instead.

Generating a JWT

When users log in to PrintBay, we're going to generate a JSON Web Token and send it back to them.

This token will also be stored on the user model so that when the token is later used to authenticate a call, we can match the token to the user.

This means we need to enhance our User schema to store the token by adding a new property token and making it's type a String.

server/models/user.js

const UserSchema = mongoose.Schema({
  name: { ... },
  email: { ... },

To view the complete lesson you'll need to login or join this course.


Click to load comments...