feat: add compatible for captcha request with challenge (#8827)
This commit is contained in:
@@ -88,15 +88,14 @@ export class CaptchaService {
|
|||||||
|
|
||||||
async verifyRequest(credential: Credential, req: Request) {
|
async verifyRequest(credential: Credential, req: Request) {
|
||||||
const challenge = credential.challenge;
|
const challenge = credential.challenge;
|
||||||
|
let resource: string | null = null;
|
||||||
if (typeof challenge === 'string' && challenge) {
|
if (typeof challenge === 'string' && challenge) {
|
||||||
const resource = await this.token
|
resource = await this.token
|
||||||
.getToken(TokenType.Challenge, challenge)
|
.getToken(TokenType.Challenge, challenge)
|
||||||
.then(token => token?.credential);
|
.then(token => token?.credential || null);
|
||||||
|
|
||||||
if (!resource) {
|
|
||||||
throw new CaptchaVerificationFailed('Invalid Challenge');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (resource) {
|
||||||
const isChallengeVerified = await this.verifyChallengeResponse(
|
const isChallengeVerified = await this.verifyChallengeResponse(
|
||||||
credential.token,
|
credential.token,
|
||||||
resource
|
resource
|
||||||
|
|||||||
Reference in New Issue
Block a user