Skip to content

Commit

Permalink
added auth.js for authentication in utils folder
Browse files Browse the repository at this point in the history
  • Loading branch information
aksharma27 committed Jan 12, 2023
1 parent a7270e0 commit 47e5e98
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions utils/auth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const jwt = require('jsonwebtoken');

exports.createJWT =(email, userId, duration) => {
const payload = {
email, userId, duration
};
return jwt.sign(payload, process.env.TOKEN_SECRET,{
expiresIn: duration,
});
};


//check code if required for signup/signin

// https://medium.com/swlh/user-authentication-using-mern-stack-part-1-backend-cd4d193f15b1

0 comments on commit 47e5e98

Please sign in to comment.