From df8a9c843622cb1bac7e9b5b12a3269bc9a20bc5 Mon Sep 17 00:00:00 2001 From: JBB0807 <104856796+JBB0807@users.noreply.github.com> Date: Mon, 5 May 2025 18:49:15 -0700 Subject: [PATCH] converted verification and query(read) using qr code number --- assignment-db-service/app.js | 4 ++-- assignment-service/routes/StudentRouter.js | 18 +++++++++--------- assignment-service/server.js | 2 +- auth-service/.env.development | 2 +- auth-service/passport.js | 6 +++--- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/assignment-db-service/app.js b/assignment-db-service/app.js index 9f43b2f..f35f6d8 100644 --- a/assignment-db-service/app.js +++ b/assignment-db-service/app.js @@ -104,10 +104,10 @@ app.get("/assignments/instructor/:instructorId", async (req, res) => { }); // Read Assignment -app.get("/assignments/:id", async (req, res) => { +app.get("/assignments/:qrNumber", async (req, res) => { try { const assignment = await prisma.assignments.findUnique({ - where: { assignmentid: parseInt(req.params.id) }, + where: { qrcodenumber: parseInt(req.params.qrNumber) }, }); if (!assignment) { diff --git a/assignment-service/routes/StudentRouter.js b/assignment-service/routes/StudentRouter.js index d57339a..0107595 100644 --- a/assignment-service/routes/StudentRouter.js +++ b/assignment-service/routes/StudentRouter.js @@ -10,11 +10,11 @@ studentRouter.post("/save", (req, res) => {}); studentRouter.post("/deploy", (req, res) => {}); -studentRouter.get("/assignment/:id", (req, res) => { - const assignmentId = req.params.id; - console.log("Fetching details for assignmentId:", assignmentId); +studentRouter.get("/assignment/:qrnum", (req, res) => { + const qrnum = req.params.qrnum; + console.log("Fetching details for qr number:", qrnum); axios - .get(`${DB_ASSIGNMENT_SERVICE_URL}/assignments/${assignmentId}`) + .get(`${DB_ASSIGNMENT_SERVICE_URL}/assignments/${qrnum}`) .then((response) => { console.log("Response from DB_ASSIGNMENT_SERVICE_URL:", response.data); res.status(response.status).json(response.data); @@ -27,20 +27,20 @@ studentRouter.get("/assignment/:id", (req, res) => { studentRouter.post("/verify", async (req, res) => { try { - const assignmentId = req.body.assignmentId; + const qrNumber = req.body.qrNumber; const password = req.body.password; console.log("Received request to verify assignment."); console.log("Request body:", req.body); console.log( - "Accessing assignment with ID:", - assignmentId, + "Accessing assignment with QR Number:", + qrNumber, "and password:", password ); - console.log(`Fetching from URL: ${DB_ASSIGNMENT_SERVICE_URL}/assignments/${assignmentId}`); + console.log(`Fetching from URL: ${DB_ASSIGNMENT_SERVICE_URL}/assignments/${qrNumber}`); const response = await axios.get( - `${DB_ASSIGNMENT_SERVICE_URL}/assignments/${assignmentId}` + `${DB_ASSIGNMENT_SERVICE_URL}/assignments/${qrNumber}` ); console.log("Response from DB_ASSIGNMENT_SERVICE_URL:", response.data); diff --git a/assignment-service/server.js b/assignment-service/server.js index b7918bd..7c408ee 100644 --- a/assignment-service/server.js +++ b/assignment-service/server.js @@ -71,4 +71,4 @@ app.get("/notebook/:appName", async (req, res) => { }); const port = process.env.NODE_PORT || 8080; -app.listen(port, "0.0.0.0", () => console.log(`Listening on 0.0.0.0:${port}...`)); +app.listen(port, "::", () => console.log(`Listening on :::${port}...`)); diff --git a/auth-service/.env.development b/auth-service/.env.development index e302c2f..5fd061d 100644 --- a/auth-service/.env.development +++ b/auth-service/.env.development @@ -5,7 +5,7 @@ GOOGLE_CLIENT_SECRET="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" GOOGLE_CALLBACK_URL="http://localhost:8080/auth/google/callback" LOGIN_REDIRECT_URL="http://localhost:5173/" ACCEPTED_ORIGINS=http://localhost:3000,http://localhost:8081,http://localhost:3001,http://localhost:5173 -ASSIGNMENT_SERVICE_URL="http://localhost:8082/" +ASSIGNMENT_SERVICE_URL="http://localhost:8082" DB_USER_SERVICE_URL="http://localhost:3100/" AUTH_SESSION_KEY="f3f4d8e6b17a4b3abdc8e9a2c0457aaf91c0d5f6e3b7a9c8df624bd71ea35f42" PORT=8080 \ No newline at end of file diff --git a/auth-service/passport.js b/auth-service/passport.js index 8ef091d..c6b82f5 100644 --- a/auth-service/passport.js +++ b/auth-service/passport.js @@ -22,10 +22,10 @@ passport.use( passport.use( "student-auth", new CustomStrategy(async (req, done) => { - const { assignmentId, password } = req.body; + const { qrNumber, password } = req.body; console.log("Custom strategy invoked"); - console.log("Received assignmentId:", assignmentId); + console.log("Received qrNumber:", qrNumber); console.log("Received password:", password); try { @@ -33,7 +33,7 @@ passport.use( const response = await axios.post( `${process.env.ASSIGNMENT_SERVICE_URL}/student/verify`, { - assignmentId, + qrNumber, password, } );