p5.js-web-editor/server/utils/jwt.js

12 lines
274 B
JavaScript

import jwt from 'jwt-simple'
exports.generateToken = function(user) {
const timestamp = new Date().getTime();
return jwt.encode({
_id: user._id,
email: user.email,
name: user.name,
username: user.username,
iat: timestamp }, process.env.JWT_SECRET);
}