Skip to content

Commit

Permalink
update /admin/user-idv-data to also delete records from our facetec s…
Browse files Browse the repository at this point in the history
…erver
  • Loading branch information
calebtuttle committed Oct 31, 2024
1 parent e4147fa commit 79357de
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/services/admin/user-idv-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import axios from "axios";
import { ObjectId } from "mongodb";
import { subDays } from "date-fns";
import { Session } from "../../init.js";
import { sessionStatusEnum } from "../../constants/misc.js";
import { sessionStatusEnum, facetecServerBaseURL } from "../../constants/misc.js";
import { pinoOptions, logger } from "../../utils/logger.js";
import { deleteVeriffSession } from "../../utils/veriff.js";
import { deleteOnfidoApplicant } from "../../utils/onfido.js";
Expand Down Expand Up @@ -116,6 +116,24 @@ async function deleteUserData(req, res) {
await deleteDataFromIDVProvider(session);
}

// Delete records from our FaceTec Server
try {
const resp = await axios.delete(`${facetecServerBaseURL}/old-enrollments`, {
headers: {
"X-Api-Key": process.env.FACETEC_SERVER_API_KEY,
},
});
// For now, we log the result. Probably not necessary long-term.
if (!resp.data?.deleted) {
console.log("deleteUserData: No data deleted after calling DELETE /old-enrollments on FaceTec Server. Response from server:", resp.data);
}
} catch (err) {
console.log("deleteUserData: Error encountered while calling DELETE /old-enrollments on FaceTec Server (a)", err.message);
if (err?.response?.data)
console.log("deleteUserData: Error encountered (b)", err?.response?.data);
else console.log("deleteUserData: Error encountered (b)", err);
}

return res.status(200).json({ message: "Success" });
} catch (err) {
console.log("deleteUserData: Error encountered (a)", err.message);
Expand Down

0 comments on commit 79357de

Please sign in to comment.