validateRecaptcha

suspend fun RoutingContext.validateRecaptcha(config: RecaptchaConfig, params: Parameters): Boolean

Validates the reCAPTCHA response token from form parameters within a Ktor RoutingContext.

If reCAPTCHA is configured and the token is missing or invalid, this function responds with an HTTP 400 Bad Request and returns false. Returns true when validation succeeds or reCAPTCHA is not configured.

Return

true if validation passed or reCAPTCHA is disabled, false otherwise.

Parameters

config

the RecaptchaConfig providing keys and enabled status.

params

the form Parameters containing the g-recaptcha-response token.