Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

feat: add compatible for captcha request with challenge (#8827)

DarkSky129cceade954
diff --git a/packages/backend/server/src/plugins/captcha/service.ts b/packages/backend/server/src/plugins/captcha/service.ts
index d3ebafdfd0..7b8f1c3986 100644
--- a/packages/backend/server/src/plugins/captcha/service.ts
+++ b/packages/backend/server/src/plugins/captcha/service.ts
@@ -88,15 +88,14 @@ export class CaptchaService {
async verifyRequest(credential: Credential, req: Request) {
const challenge = credential.challenge;
+ let resource: string | null = null;
if (typeof challenge === 'string' && challenge) {
- const resource = await this.token
+ resource = await this.token
.getToken(TokenType.Challenge, challenge)
- .then(token => token?.credential);
-
- if (!resource) {
- throw new CaptchaVerificationFailed('Invalid Challenge');
- }
+ .then(token => token?.credential || null);
+ }
+ if (resource) {
const isChallengeVerified = await this.verifyChallengeResponse(
credential.token,
resource