forked from bro-students/multy-stub
15 lines
303 B
JavaScript
15 lines
303 B
JavaScript
|
const authMiddleware = (req, res, next) => {
|
||
|
const email = (req.headers.authorization || "").replace("Bearer ", "");
|
||
|
|
||
|
if (email) {
|
||
|
req.userEmail = email;
|
||
|
next();
|
||
|
} else {
|
||
|
return res.status(403).json({
|
||
|
message: "Access Denied",
|
||
|
});
|
||
|
}
|
||
|
};
|
||
|
|
||
|
module.exports = authMiddleware
|