mirror of
https://github.com/Ride-The-Lightning/RTL
synced 2024-11-03 23:15:24 +00:00
16 lines
394 B
JavaScript
16 lines
394 B
JavaScript
const jwt = require("jsonwebtoken");
|
|
var common = require('../common');
|
|
|
|
module.exports = (req, res, next) => {
|
|
try {
|
|
const token = req.headers.authorization.split(" ")[1];
|
|
jwt.verify(token, common.secret_key);
|
|
next();
|
|
} catch (error) {
|
|
res.status(401).json({
|
|
message: "Authentication Failed!",
|
|
error: "Authentication Failed! Please Login First!"
|
|
});
|
|
}
|
|
};
|