-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from chvarkov/develop
Added override ability default recaptcha property.
- Loading branch information
Showing
7 changed files
with
38 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
import { UseGuards } from '@nestjs/common'; | ||
import { applyDecorators, SetMetadata, UseGuards } from '@nestjs/common'; | ||
import { GoogleRecaptchaGuard } from '../guards/google-recaptcha.guard'; | ||
import { RecaptchaResponseProvider } from '../types'; | ||
import { RECAPTCHA_RESPONSE_PROVIDER } from '../provider.declarations'; | ||
|
||
export function Recaptcha(): MethodDecorator { | ||
return UseGuards(GoogleRecaptchaGuard); | ||
export function Recaptcha(response?: RecaptchaResponseProvider): MethodDecorator { | ||
return applyDecorators( | ||
SetMetadata(RECAPTCHA_RESPONSE_PROVIDER, response), | ||
UseGuards(GoogleRecaptchaGuard), | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
import { RecaptchaResponseProvider } from '../types'; | ||
|
||
export interface GoogleRecaptchaGuardOptions { | ||
response: (req) => string | Promise<string>; | ||
response: RecaptchaResponseProvider; | ||
skipIf?: () => boolean | Promise<boolean>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
export const RECAPTCHA_OPTIONS = Symbol('RECAPTCHA_OPTIONS'); | ||
|
||
export const RECAPTCHA_RESPONSE_PROVIDER = Symbol('RECAPTCHA_RESPONSE_PROVIDER'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export type RecaptchaResponseProvider = (req) => string | Promise<string>; |