Skip to content

Instantly share code, notes, and snippets.

@dimitrisdovinos
Last active January 18, 2019 14:34
Show Gist options
  • Save dimitrisdovinos/c13e98126ee2f025ad4aab0270fb6b6c to your computer and use it in GitHub Desktop.
Save dimitrisdovinos/c13e98126ee2f025ad4aab0270fb6b6c to your computer and use it in GitHub Desktop.
const jwt = require('jsonwebtoken');
function generateAuthToken(user) {
const token = jwt.sign(
{
id: user.id,
email: user.email,
firstName: user.firstName,
lastName: user.lastName,
avatarUrl: user.avatarUrl,
bannerUrl: user.bannerUrl,
isApproved: user.isApproved,
role: user.role,
},
config.secret,
);
return token;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment