diff --git a/final_project/index.js b/final_project/index.js index b890c1d380..3756159059 100644 --- a/final_project/index.js +++ b/final_project/index.js @@ -11,7 +11,19 @@ app.use(express.json()); app.use("/customer",session({secret:"fingerprint_customer",resave: true, saveUninitialized: true})) app.use("/customer/auth/*", function auth(req,res,next){ -//Write the authenication mechanism here + if(req.session.authorization){ + let token = req.session.authorization['accessToken']; + jwt.verify(token, "access",(err,user)=>{ + if(!err){ + req.user = user; + next(); + }else{ + return res.status(403).json({message: "User not authenticaated"}); + } + }) + }else{ + return res.status(403).json({message: "User not logged in"}); + } }); const PORT =5000;