converted verification and query(read) using qr code number

This commit is contained in:
JBB0807 2025-05-05 18:49:15 -07:00
parent 426f0c60c2
commit df8a9c8436
5 changed files with 16 additions and 16 deletions

View file

@ -104,10 +104,10 @@ app.get("/assignments/instructor/:instructorId", async (req, res) => {
}); });
// Read Assignment // Read Assignment
app.get("/assignments/:id", async (req, res) => { app.get("/assignments/:qrNumber", async (req, res) => {
try { try {
const assignment = await prisma.assignments.findUnique({ const assignment = await prisma.assignments.findUnique({
where: { assignmentid: parseInt(req.params.id) }, where: { qrcodenumber: parseInt(req.params.qrNumber) },
}); });
if (!assignment) { if (!assignment) {

View file

@ -10,11 +10,11 @@ studentRouter.post("/save", (req, res) => {});
studentRouter.post("/deploy", (req, res) => {}); studentRouter.post("/deploy", (req, res) => {});
studentRouter.get("/assignment/:id", (req, res) => { studentRouter.get("/assignment/:qrnum", (req, res) => {
const assignmentId = req.params.id; const qrnum = req.params.qrnum;
console.log("Fetching details for assignmentId:", assignmentId); console.log("Fetching details for qr number:", qrnum);
axios axios
.get(`${DB_ASSIGNMENT_SERVICE_URL}/assignments/${assignmentId}`) .get(`${DB_ASSIGNMENT_SERVICE_URL}/assignments/${qrnum}`)
.then((response) => { .then((response) => {
console.log("Response from DB_ASSIGNMENT_SERVICE_URL:", response.data); console.log("Response from DB_ASSIGNMENT_SERVICE_URL:", response.data);
res.status(response.status).json(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) => { studentRouter.post("/verify", async (req, res) => {
try { try {
const assignmentId = req.body.assignmentId; const qrNumber = req.body.qrNumber;
const password = req.body.password; const password = req.body.password;
console.log("Received request to verify assignment."); console.log("Received request to verify assignment.");
console.log("Request body:", req.body); console.log("Request body:", req.body);
console.log( console.log(
"Accessing assignment with ID:", "Accessing assignment with QR Number:",
assignmentId, qrNumber,
"and password:", "and password:",
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( 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); console.log("Response from DB_ASSIGNMENT_SERVICE_URL:", response.data);

View file

@ -71,4 +71,4 @@ app.get("/notebook/:appName", async (req, res) => {
}); });
const port = process.env.NODE_PORT || 8080; 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}...`));

View file

@ -5,7 +5,7 @@ GOOGLE_CLIENT_SECRET="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"
GOOGLE_CALLBACK_URL="http://localhost:8080/auth/google/callback" GOOGLE_CALLBACK_URL="http://localhost:8080/auth/google/callback"
LOGIN_REDIRECT_URL="http://localhost:5173/" LOGIN_REDIRECT_URL="http://localhost:5173/"
ACCEPTED_ORIGINS=http://localhost:3000,http://localhost:8081,http://localhost:3001,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/" DB_USER_SERVICE_URL="http://localhost:3100/"
AUTH_SESSION_KEY="f3f4d8e6b17a4b3abdc8e9a2c0457aaf91c0d5f6e3b7a9c8df624bd71ea35f42" AUTH_SESSION_KEY="f3f4d8e6b17a4b3abdc8e9a2c0457aaf91c0d5f6e3b7a9c8df624bd71ea35f42"
PORT=8080 PORT=8080

View file

@ -22,10 +22,10 @@ passport.use(
passport.use( passport.use(
"student-auth", "student-auth",
new CustomStrategy(async (req, done) => { new CustomStrategy(async (req, done) => {
const { assignmentId, password } = req.body; const { qrNumber, password } = req.body;
console.log("Custom strategy invoked"); console.log("Custom strategy invoked");
console.log("Received assignmentId:", assignmentId); console.log("Received qrNumber:", qrNumber);
console.log("Received password:", password); console.log("Received password:", password);
try { try {
@ -33,7 +33,7 @@ passport.use(
const response = await axios.post( const response = await axios.post(
`${process.env.ASSIGNMENT_SERVICE_URL}/student/verify`, `${process.env.ASSIGNMENT_SERVICE_URL}/student/verify`,
{ {
assignmentId, qrNumber,
password, password,
} }
); );