Skip to content

Commit

Permalink
server verify bugfix (#1488)
Browse files Browse the repository at this point in the history
  • Loading branch information
HughParry authored Oct 30, 2024
1 parent cb064a7 commit 0e086b9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/provider/src/tasks/powCaptcha/powTasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
// limitations under the License.
import type { KeyringPair } from "@polkadot/keyring/types";
import { stringToHex, u8aToHex } from "@polkadot/util";
import { ProsopoEnvError, getLoggerDefault } from "@prosopo/common";
import {
ProsopoApiError,
ProsopoEnvError,
getLoggerDefault,
} from "@prosopo/common";
import {
ApiParams,
type CaptchaResult,
Expand Down Expand Up @@ -179,6 +183,15 @@ export class PowCaptchaManager {
});
}

if (challengeRecord.result.status !== CaptchaStatus.approved) {
throw new ProsopoApiError("CAPTCHA.INVALID_SOLUTION", {
context: {
failedFuncName: this.serverVerifyPowCaptchaSolution.name,
challenge,
},
});
}

if (challengeRecord.serverChecked) return false;

const challengeDappAccount = challengeRecord.dappAccount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ describe("PowCaptchaManager", () => {
userAccount,
timestamp,
checked: false,
result: { status: CaptchaStatus.approved },
};
// biome-ignore lint/suspicious/noExplicitAny: TODO fix
(db.getPowCaptchaRecordByChallenge as any).mockResolvedValue(
Expand Down

0 comments on commit 0e086b9

Please sign in to comment.