JWT signing and verification
//An .env file can be kept from the git commits in the gitignore
jwtSecret = "migracodeAuthJan2021"
//An external JWT generator to be imported in different files
const jwt = require("jsonwebtoken");
require("dotenv").config();
function generateJWT(user_id) {
const payload = {
user: {
id: user_id
}
};
return jwt.sign(payload, process.env.jwtSecret, { expiresIn: "1h" });
}
module.exports = generateJWT;
PreviousHTTP protocol, create-react-app configuration, and Cookies settingNextNODE 2 explaining the fetch.
Last updated