You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If an extension call would be added to validate, this would devs to tweak the validation result without having to duplicate/replace the existing validation logic.
Use case is a subsites setup (with reCaptcha v3) to which new hostnames may be added by the client. These hostnames should then also be added to the reCaptcha key in order to work. Instead, the reCaptcha key is marked as 'do not check origin' and we are required to check the hostname field ourselves.
Currently we override the field with our own subclass (via Injector) but an extension hook would be better imo, eg just before return true in validate(): $this->extend('extendValidation', $validator);
Note: get the response in an extension via $this->owner->getVerifyResponse(), no need to include that as argument.
Logic for hostname validation:
class NocaptchaField_ValidateSubsiteHostname
extends NocaptchaField {
publicfunctionvalidate($validator)
{
$isValid = parent::validate($validator);
// Extra check: validate hostname the recaptcha was solved on to be a valid subsite domain$response = $this->getVerifyResponse();
if( isset($response['hostname']) && Subsite::getSubsiteIDForDomain($response['hostname']) !== SubsiteState::singleton()->getSubsiteId() ) {
$validator->validationError($this->name, _t(__CLASS__.'.SPAM', 'Invalid hostname in validation response: SPAM'));
returnfalse;
}
return$isValid;
}
}
The text was updated successfully, but these errors were encountered:
If an extension call would be added to validate, this would devs to tweak the validation result without having to duplicate/replace the existing validation logic.
Use case is a subsites setup (with reCaptcha v3) to which new hostnames may be added by the client. These hostnames should then also be added to the reCaptcha key in order to work. Instead, the reCaptcha key is marked as 'do not check origin' and we are required to check the hostname field ourselves.
Currently we override the field with our own subclass (via Injector) but an extension hook would be better imo, eg just before
return true
in validate():$this->extend('extendValidation', $validator);
Note: get the response in an extension via
$this->owner->getVerifyResponse()
, no need to include that as argument.Logic for hostname validation:
The text was updated successfully, but these errors were encountered: