2
0
mirror of https://github.com/Ride-The-Lightning/RTL synced 2024-11-15 18:13:00 +00:00
RTL/routes/authCheck.js

16 lines
394 B
JavaScript
Raw Normal View History

2019-01-01 16:26:51 +00:00
const jwt = require("jsonwebtoken");
2019-02-24 17:00:39 +00:00
var common = require('../common');
2019-01-01 16:26:51 +00:00
module.exports = (req, res, next) => {
try {
const token = req.headers.authorization.split(" ")[1];
2019-02-24 17:00:39 +00:00
jwt.verify(token, common.secret_key);
2019-01-01 16:26:51 +00:00
next();
} catch (error) {
res.status(401).json({
message: "Authentication Failed!",
error: "Authentication Failed! Please Login First!"
});
}
};