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

This commit is contained in:
DarkSky
2024-11-14 18:22:02 +08:00
committed by GitHub
parent 055fa0a8b4
commit 129cceade9

View File

@@ -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