Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module.exports = (req, resp, next) => {
- "use strict";
- let userToken = req.header('x-access-token');
- if (!userToken) {
- return resp.status(HTTPStatus.UNAUTHORIZED).send({
- "status": "error",
- "message": "Unauthorized Access"
- });
- }
- jwt.verify(userToken, appConfig.APP_SECRET, (err, decoded) => {
- if (err) {
- return resp.status(HTTPStatus.INTERNAL_SERVER_ERROR).send({
- "status": "error",
- "message": "Unable To Verify User Token"
- });
- }
- req.body.userID = decoded;
- next();
- });
- };
Add Comment
Please, Sign In to add comment