Skip to content

Commit

Permalink
Store token at correct point (#1576) (#1577)
Browse files Browse the repository at this point in the history
Co-authored-by: Hugh <[email protected]>
  • Loading branch information
forgetso and HughParry authored Dec 19, 2024
1 parent 24c2ccb commit cb0d8f0
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions packages/provider/src/api/captcha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,13 +447,6 @@ export function prosopoRouter(env: ProviderEnvironment): Router {
clientConfig?.settings?.frictionlessThreshold ||
DEFAULT_FRICTIONLESS_THRESHOLD;

// Store the token
const tokenId = await tasks.db.storeFrictionlessTokenRecord({
token,
score: botScore,
threshold: botThreshold,
});

// Check if the IP address is blocked
const ipAddress = getIPAddress(req.ip || "");
const isIpBlocked = await tasks.frictionlessManager.checkIpRules(
Expand All @@ -475,8 +468,16 @@ export function prosopoRouter(env: ProviderEnvironment): Router {
if (Number(botScore) > botThreshold)
return res.json(tasks.frictionlessManager.sendImageCaptcha());

// Store the token
const tokenId = await tasks.db.storeFrictionlessTokenRecord({
token,
score: botScore,
threshold: botThreshold,
});

const response =
await tasks.frictionlessManager.sendPowCaptcha(tokenId);

return res.json(response);
} catch (err) {
console.error("Error in frictionless captcha challenge:", err);
Expand Down

0 comments on commit cb0d8f0

Please sign in to comment.