MCPcopy Create free account
hub / github.com/basir/node-react-ecommerce / getToken

Function getToken

backend/util.js:3–16  ·  view source on GitHub ↗
(user)

Source from the content-addressed store, hash-verified

1import jwt from 'jsonwebtoken';
2import config from './config';
3const getToken = (user) => {
4 return jwt.sign(
5 {
6 _id: user._id,
7 name: user.name,
8 email: user.email,
9 isAdmin: user.isAdmin,
10 },
11 config.JWT_SECRET,
12 {
13 expiresIn: '48h',
14 }
15 );
16};
17
18const isAuth = (req, res, next) => {
19 const token = req.headers.authorization;

Callers 1

userRoute.jsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected