Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
calebtuttle committed May 6, 2024
1 parent 0ee5f32 commit ad11522
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/services/sessions/endpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,19 @@ async function postSession(req, res) {
const resp = await axios.get(
`https://ipapi.co/${userIp}/json?key=${process.env.IPAPI_SECRET_KEY}`
);
const ipCountry = resp?.data?.country_name;
const ipCountry = resp?.data?.country;

if (!ipCountry) {
return res.status(500).json({ error: "Could not determine country from IP" });
}

const session = new Session({
sigDigest: sigDigest,
idvProvider: idvProvider,
status: sessionStatusEnum.NEEDS_PAYMENT,
frontendDomain: domain,
silkDiffWallet,
ipCountry: ipCountry ?? null, // prefer null over undefined
ipCountry: ipCountry,
});
await session.save();

Expand Down

0 comments on commit ad11522

Please sign in to comment.