Skip to content

Commit

Permalink
fix for sessionIds that dont have persona attached
Browse files Browse the repository at this point in the history
  • Loading branch information
endimion committed Jun 10, 2024
1 parent 7273605 commit 45e81fb
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 20 deletions.
12 changes: 9 additions & 3 deletions routes/educationalRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,18 @@ educationalRouter.get(["/pre-offer-jwt-edu"], async (req, res) => {
const uuid = req.query.sessionId ? req.query.sessionId : uuidv4();
const personaId = req.query.persona;
const preSessions = getPreCodeSessions();
if (preSessions.sessions.indexOf(uuid + "-persona=" + personaId) < 0) {
preSessions.sessions.push(uuid + "-persona=" + personaId);
//if (preSessions.sessions.indexOf(uuid + "-persona=" + personaId) < 0) {
// preSessions.sessions.push(uuid + "-persona=" + personaId);
// preSessions.results.push({ sessionId: uuid, status: "pending" });
// preSessions.personas.push(null);
// preSessions.accessTokens.push(null);
// }
if (preSessions.sessions.indexOf(uuid ) < 0) {
preSessions.sessions.push(uuid);
preSessions.results.push({ sessionId: uuid, status: "pending" });
preSessions.personas.push(null);
preSessions.accessTokens.push(null);
}
}
let credentialOffer = "";
if (personaId) {
credentialOffer = `openid-credential-offer://?credential_offer_uri=${serverURL}/credential-offer-pre-jwt-edu/${uuid}?persona=${personaId}`; //OfferUUID
Expand Down
18 changes: 9 additions & 9 deletions routes/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -852,15 +852,15 @@ function checkIfExistsIssuanceStatus(
let index = sessions.indexOf(sessionId);
console.log("index is");
console.log(index);
if (index < 0) {
sessions.forEach((value, _index) => {
console.log("checking value to " + value.replace(/-persona=\s+$/, "") +"-checking vs" + sessionId)
if (value.replace(/-persona=.*$/, "") === sessionId) {
console.log("updated index")
index = _index;
}
});
}
// if (index < 0) {
// sessions.forEach((value, _index) => {
// console.log("checking value to " + value.replace(/-persona=\s+$/, "") +"-checking vs" + sessionId)
// if (value.replace(/-persona=.*$/, "") === sessionId) {
// console.log("updated index")
// index = _index;
// }
// });
// }
if (index >= 0) {
let status = sessionResults[index].status;
console.log(`sending status ${status} for session ${sessionId}`);
Expand Down
16 changes: 8 additions & 8 deletions routes/verifierRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,14 +349,14 @@ verifierRouter.post("/direct_post_jwt/:id", async (req, res) => {
verifierRouter.get(["/verificationStatus"], (req, res) => {
let sessionId = req.query.sessionId;
let index = sessions.indexOf(sessionId); // sessions.indexOf(sessionId+""); //
if (index < 0) {
sessions.forEach((value, _index) => {
if (value.replace(/-persona=.*$/, "") === sessionId) {
console.log("updated index");
index = _index;
}
});
}
// if (index < 0) {
// sessions.forEach((value, _index) => {
// if (value.replace(/-persona=.*$/, "") === sessionId) {
// console.log("updated index");
// index = _index;
// }
// });
// }
console.log("index is");
console.log(index);
let result = null;
Expand Down

0 comments on commit 45e81fb

Please sign in to comment.