@nestlab/google-recaptcha
Advanced tools
Comparing version 2.0.3 to 2.0.4
@@ -43,7 +43,7 @@ "use strict"; | ||
const action = options === null || options === void 0 ? void 0 : options.action; | ||
const result = await this.validator.validate({ response, score, action }); | ||
if (result.success) { | ||
request.recaptchaValidationResult = await this.validator.validate({ response, score, action }); | ||
if (request.recaptchaValidationResult.success) { | ||
return true; | ||
} | ||
throw new google_recaptcha_exception_1.GoogleRecaptchaException(result.errors); | ||
throw new google_recaptcha_exception_1.GoogleRecaptchaException(request.recaptchaValidationResult.errors); | ||
} | ||
@@ -50,0 +50,0 @@ }; |
import { ErrorCode } from '../enums/error-code'; | ||
export interface GoogleRecaptchaValidationResult { | ||
import { VerifyResponseV2 } from './verify-response'; | ||
export interface GoogleRecaptchaValidationResult extends VerifyResponseV2 { | ||
success: boolean; | ||
hostname: string; | ||
action?: string; | ||
score?: number; | ||
errors: ErrorCode[]; | ||
} |
{ | ||
"name": "@nestlab/google-recaptcha", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"description": "Google recaptcha module for NestJS.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -191,2 +191,18 @@ # Google recaptcha module | ||
Get verification result | ||
```typescript | ||
@Controller('feedback') | ||
export class FeedbackController { | ||
@Recaptcha() | ||
@Post('send') | ||
async send(@RecaptchaResult() recaptchaResult: GoogleRecaptchaValidationResult): Promise<any> { | ||
console.log(`Action: ${recaptchaResult.action} Score: ${recaptchaResult.score}`); | ||
// TODO: Your implementation. | ||
} | ||
} | ||
``` | ||
If you want use google recaptcha guard in combination with another guards then you can use `@UseGuards` decorator. | ||
@@ -193,0 +209,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
55940
67
595
296