Skip to content
Snippets Groups Projects
Commit 28dfdd69 authored by mperezsa's avatar mperezsa
Browse files

Upload New File

parent d8586d80
No related branches found
No related tags found
No related merge requests found
const jwt = require("jsonwebtoken");
const auth = async (req, res, next) => {
try {
//console.log(req.headers.authorization);
const token = req.headers.authorization.split(" ")[1];
// Other Tokens Like Google ones have a length > 500 ( Used in case of setting up another authentification system )
const isCustomAuth = token.length < 500;
let decodedData;
if (token && isCustomAuth) {
decodedData = jwt.verify(token, process.env.JWT_SECRET);
req.userId = decodedData.id;
req.userEmail = decodedData.email;
//console.log(decodedData.email + " Connected !");
}
next();
} catch (err) {
console.log(err);
}
};
module.exports = auth;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment