Skip to content

Completed final project tasks #344

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 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions final_project/cookies.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Netscape HTTP Cookie File
# https://curl.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.

#HttpOnly_localhost FALSE / FALSE 0 connect.sid s%3A0mYTWn0iD908DOv1jTHJpXfFrA1QLcAW.zExv8oSY1n3IgPlEgkvrqu0RGKJsIiH5rFPagr0Q8ck
14 changes: 12 additions & 2 deletions final_project/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,18 @@ 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
app.use("/customer/auth/*", function auth(req, res, next) {
const token = req.session.token;
if (!token) {
return res.status(401).json({ message: "No token provided" });
}
try {
const decoded = jwt.verify(token, "fingerprint_customer");
req.user = decoded;
next();
} catch (err) {
return res.status(401).json({ message: "Invalid token" });
}
});

const PORT =5000;
Expand Down
Loading