mirror of
https://github.com/yusufipk/RememberMe.git
synced 2026-09-11 10:56:07 +00:00
created(auth) auth middleware has been added and used on person route
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
const jwt = require("jsonwebtoken");
|
||||
|
||||
module.exports = function auth(req, res, next) {
|
||||
const token = req.header("x-auth-token");
|
||||
if (!token) return res.status(401).send("Access denied! No token provided.");
|
||||
|
||||
try {
|
||||
jwt.verify(token, process.env.rememberMe_jwtKey);
|
||||
next();
|
||||
} catch (ex) {
|
||||
return res.status(400).send("Invalid token.");
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user