Skip to content

Completed final project of the course : Developing Back-End apps with Node.js and Express #322

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
19 changes: 18 additions & 1 deletion final_project/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,24 @@ 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 {
res.status(403).json({message : "User is not authenticated"});
}
})
}
else {
res.status(403).json({message : "User is not logged in. Please login first"});
}


});

const PORT =5000;
Expand Down
Loading