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: { ... },
Click to load comments...