Giter VIP home page Giter VIP logo

google-recaptcha-example's People

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

cariaga

google-recaptcha-example's Issues

When guarding gql resolver, request provided to response() is "undefined"

Working on utilizing this guard on a resolver, and am having trouble getting the request to be defined :/

image

I have a resolver on the left that's guarded by @Recaptcha, and my configured response method logs whatever it receives as input:

useFactory: (config: ConfigService) => {
                return {
                    secretKey: "6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe",
                    response: req => {
                        console.log("request made:", req)
                        return req.headers.recaptcha
                    }
                }
            }

Any idea why I can't see any of my request information? Read through the docs extensively but can't find any existing GQL examples. Would be happy to publish a sandbox once it's all workin.

Thanks for any assistance, appreciate your time.

Error when using `GoogleRecaptchaGuard` or `@Recaptcha()` decorator

Hello

I have tried to implement recaptcha with this module but currently hitting a wall.

  • Using the GoogleRecaptchaGuard by itself with @UseGuards()
  • Using the @Recaptcha() decorator alone
  • Using both
@UseGuards(GoogleRecaptchaGuard)
  @Recaptcha()
  @Get('recaptcha')
  async recaptcha() {
    return true;
  } 

The error

TypeError: Cannot read properties of undefined (reading 'valid')
    at GoogleRecaptchaEnterpriseValidator.validate (/Users/gmwill934/Documents/tlantli/api/node_modules/@nestlab/src/services/validators/google-recaptcha-enterprise.validator.ts:36:41)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at GoogleRecaptchaGuard.canActivate (/Users/gmwill934/Documents/tlantli/api/node_modules/@nestlab/src/guards/google-recaptcha.guard.ts:41:39)
    at GuardsConsumer.tryActivate (/Users/gmwill934/Documents/tlantli/api/node_modules/@nestjs/core/guards/guards-consumer.js:16:17)
    at canActivateFn (/Users/gmwill934/Documents/tlantli/api/node_modules/@nestjs/core/router/router-execution-context.js:134:33)
    at /Users/gmwill934/Documents/tlantli/api/node_modules/@nestjs/core/router/router-execution-context.js:42:31
    at /Users/gmwill934/Documents/tlantli/api/node_modules/@nestjs/core/router/router-proxy.js:9:17

This is how I initialize this module on my app.module.ts file

GoogleRecaptchaModule.forRoot({
      response: (req: IncomingMessage) => {
        return (req.headers.recaptcha || '').toString();
      },
      actions: ['RegisterAccount'],
      score: 0.8,
      enterprise: {
        projectId: 'project-id',
        siteKey: 'site-key',
        apiKey: 'api-key',
      },
    }),

Inject on Interceptor so I can use it

constructor(
    private readonly mailService: MailService,
    private readonly recaptchaGoogleEnterprise: GoogleRecaptchaEnterpriseValidator,
  ) {}

Am I missing something?

Thanks

Integrate with more than 1 reCAPTCHA projects

Hi,

In a particular cases, we would have both V2/V3 integration in our application for different scenario. Just wonder if we could make this non-global so that I can have separate instance with different secret key?

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.