Skip to content

Instantly share code, notes, and snippets.

@iskenxan
Created April 14, 2019 22:20
Show Gist options
  • Save iskenxan/c8dcf798b4a5b9a4eabe6d9520814da0 to your computer and use it in GitHub Desktop.
Save iskenxan/c8dcf798b4a5b9a4eabe6d9520814da0 to your computer and use it in GitHub Desktop.
jwt = require('jsonwebtoken');
const ADMINS = ['[email protected]'];
module.exports = function createToken(userEmail) {
let access = userEmail;
ADMINS.forEach(email => {
if (email === userEmail)
access = 'admin'
});
const token = jwt.sign({
access,
}, 'secret');
return token;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment