From a622fa219894d5eea5663ea75bbdc02e37fa636c Mon Sep 17 00:00:00 2001 From: florinsilva <121447369+FlorinNatha@users.noreply.github.com> Date: Sat, 19 Apr 2025 12:35:52 +0530 Subject: [PATCH] Update index.js --- final_project/index.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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;