Some Refactoring Done
This commit is contained in:
parent
63f4d88dee
commit
b746987075
|
|
@ -125,6 +125,33 @@ class Captcha implements CaptchaContract
|
|||
return json_decode($response->getBody())->success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get or merge existing validations with your captcha validations.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getValidations($rules = []): array
|
||||
{
|
||||
return $this->isActive()
|
||||
? array_merge($rules, ['g-recaptcha-response' => 'required|captcha'])
|
||||
: $rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get or merge existing validation messages with your captcha validation messages.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getValidationMessages($messages = []): array
|
||||
{
|
||||
return $this->isActive()
|
||||
? array_merge($messages, [
|
||||
'g-recaptcha-response.required' => __('customer::app.admin.system.captcha.validations.required'),
|
||||
'g-recaptcha-response.captcha' => __('customer::app.admin.system.captcha.validations.captcha')
|
||||
])
|
||||
: $messages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get attributes.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -33,9 +33,7 @@ class CustomerForgotPasswordRequest extends FormRequest
|
|||
*/
|
||||
public function rules()
|
||||
{
|
||||
return Captcha::isActive()
|
||||
? array_merge($this->rules, ['g-recaptcha-response' => 'required|captcha'])
|
||||
: $this->rules;
|
||||
return Captcha::getValidations($this->rules);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -45,9 +43,6 @@ class CustomerForgotPasswordRequest extends FormRequest
|
|||
*/
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'g-recaptcha-response.required' => __('customer::app.admin.system.captcha.validations.required'),
|
||||
'g-recaptcha-response.captcha' => __('customer::app.admin.system.captcha.validations.captcha')
|
||||
];
|
||||
return Captcha::getValidationMessages();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,9 +34,7 @@ class CustomerLoginRequest extends FormRequest
|
|||
*/
|
||||
public function rules()
|
||||
{
|
||||
return Captcha::isActive()
|
||||
? array_merge($this->rules, ['g-recaptcha-response' => 'required|captcha'])
|
||||
: $this->rules;
|
||||
return Captcha::getValidations($this->rules);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -46,8 +44,6 @@ class CustomerLoginRequest extends FormRequest
|
|||
*/
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'g-recaptcha-response.required' => __('customer::app.admin.system.captcha.validations.required')
|
||||
];
|
||||
return Captcha::getValidationMessages();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,9 +36,7 @@ class CustomerRegistrationRequest extends FormRequest
|
|||
*/
|
||||
public function rules()
|
||||
{
|
||||
return Captcha::isActive()
|
||||
? array_merge($this->rules, ['g-recaptcha-response' => 'required|captcha'])
|
||||
: $this->rules;
|
||||
return Captcha::getValidations($this->rules);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -48,8 +46,6 @@ class CustomerRegistrationRequest extends FormRequest
|
|||
*/
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'g-recaptcha-response.required' => __('customer::app.admin.system.captcha.validations.required')
|
||||
];
|
||||
return Captcha::getValidationMessages();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue