You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
397 B
JavaScript
16 lines
397 B
JavaScript
5 years ago
|
const jwt = require("jsonwebtoken");
|
||
3 years ago
|
var common = require('../../common');
|
||
5 years ago
|
|
||
|
module.exports = (req, res, next) => {
|
||
|
try {
|
||
|
const token = req.headers.authorization.split(" ")[1];
|
||
5 years ago
|
jwt.verify(token, common.secret_key);
|
||
5 years ago
|
next();
|
||
|
} catch (error) {
|
||
|
res.status(401).json({
|
||
|
message: "Authentication Failed!",
|
||
|
error: "Authentication Failed! Please Login First!"
|
||
|
});
|
||
|
}
|
||
|
};
|