Captcha Added In Forgot Password Feature
This commit is contained in:
parent
9b20f00729
commit
63f4d88dee
|
|
@ -4,13 +4,14 @@ namespace Webkul\Customer\Http\Controllers;
|
|||
|
||||
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
|
||||
use Illuminate\Support\Facades\Password;
|
||||
use Webkul\Customer\Http\Requests\CustomerForgotPasswordRequest;
|
||||
|
||||
class ForgotPasswordController extends Controller
|
||||
{
|
||||
use SendsPasswordResetEmails;
|
||||
|
||||
|
||||
/**
|
||||
* Contains route related configuration
|
||||
* Contains route related configuration.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
|
|
@ -41,16 +42,12 @@ class ForgotPasswordController extends Controller
|
|||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store()
|
||||
public function store(CustomerForgotPasswordRequest $request)
|
||||
{
|
||||
try {
|
||||
$this->validate(request(), [
|
||||
'email' => 'required|email',
|
||||
]);
|
||||
$request->validated();
|
||||
|
||||
$response = $this->broker()->sendResetLink(
|
||||
request(['email'])
|
||||
);
|
||||
try {
|
||||
$response = $this->broker()->sendResetLink($request->only(['email']));
|
||||
|
||||
if ($response == Password::RESET_LINK_SENT) {
|
||||
session()->flash('success', trans('customer::app.forget_password.reset_link_sent'));
|
||||
|
|
@ -59,7 +56,7 @@ class ForgotPasswordController extends Controller
|
|||
}
|
||||
|
||||
return back()
|
||||
->withInput(request(['email']))
|
||||
->withInput($request->only(['email']))
|
||||
->withErrors([
|
||||
'email' => trans('customer::app.forget_password.email_not_exist'),
|
||||
]);
|
||||
|
|
@ -69,6 +66,7 @@ class ForgotPasswordController extends Controller
|
|||
return redirect()->back();
|
||||
} catch (\Exception $e) {
|
||||
report($e);
|
||||
|
||||
session()->flash('error', trans($e->getMessage()));
|
||||
|
||||
return redirect()->back();
|
||||
|
|
@ -84,4 +82,4 @@ class ForgotPasswordController extends Controller
|
|||
{
|
||||
return Password::broker('customers');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Customer\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Webkul\Customer\Facades\Captcha;
|
||||
|
||||
class CustomerForgotPasswordRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Define your rules.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $rules = [
|
||||
'email' => 'required|email',
|
||||
];
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return Captcha::isActive()
|
||||
? array_merge($this->rules, ['g-recaptcha-response' => 'required|captcha'])
|
||||
: $this->rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
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')
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -31,7 +31,8 @@ return [
|
|||
'status' => 'حالة',
|
||||
|
||||
'validations' => [
|
||||
'required' => 'الرجاء اختيار CAPTCHA'
|
||||
'required' => 'الرجاء اختيار CAPTCHA',
|
||||
'captcha' => 'هناك خطأ ما! حاول مرة اخرى.',
|
||||
]
|
||||
],
|
||||
],
|
||||
|
|
|
|||
|
|
@ -31,7 +31,8 @@ return [
|
|||
'status' => 'Status',
|
||||
|
||||
'validations' => [
|
||||
'required' => 'Bitte wählen Sie CAPTCHA'
|
||||
'required' => 'Bitte wählen Sie CAPTCHA',
|
||||
'captcha' => 'Etwas ist schief gelaufen! Bitte versuche es erneut.',
|
||||
]
|
||||
],
|
||||
],
|
||||
|
|
|
|||
|
|
@ -31,7 +31,8 @@ return [
|
|||
'status' => 'Status',
|
||||
|
||||
'validations' => [
|
||||
'required' => 'Please select CAPTCHA'
|
||||
'required' => 'Please select CAPTCHA',
|
||||
'captcha' => 'Something went wrong! Please try again.',
|
||||
]
|
||||
],
|
||||
],
|
||||
|
|
|
|||
|
|
@ -31,7 +31,8 @@ return [
|
|||
'status' => 'Estado',
|
||||
|
||||
'validations' => [
|
||||
'required' => 'Seleccione CAPTCHA'
|
||||
'required' => 'Seleccione CAPTCHA',
|
||||
'captcha' => '¡Algo salió mal! Inténtalo de nuevo.',
|
||||
]
|
||||
],
|
||||
],
|
||||
|
|
|
|||
|
|
@ -31,7 +31,8 @@ return [
|
|||
'status' => 'Statut',
|
||||
|
||||
'validations' => [
|
||||
'required' => 'Veuillez sélectionner CAPTCHA'
|
||||
'required' => 'Veuillez sélectionner CAPTCHA',
|
||||
'captcha' => 'Quelque chose s\'est mal passé ! Veuillez réessayer.',
|
||||
]
|
||||
],
|
||||
],
|
||||
|
|
|
|||
|
|
@ -31,7 +31,8 @@ return [
|
|||
'status' => 'Stato',
|
||||
|
||||
'validations' => [
|
||||
'required' => 'Seleziona CAPTCHA'
|
||||
'required' => 'Seleziona CAPTCHA',
|
||||
'captcha' => 'Qualcosa è andato storto! Per favore riprova.',
|
||||
]
|
||||
],
|
||||
],
|
||||
|
|
|
|||
|
|
@ -31,7 +31,8 @@ return [
|
|||
'status' => 'Toestand',
|
||||
|
||||
'validations' => [
|
||||
'required' => 'Selecteer CAPTCHA'
|
||||
'required' => 'Selecteer CAPTCHA',
|
||||
'captcha' => 'Er is iets fout gegaan! Probeer het opnieuw.',
|
||||
]
|
||||
],
|
||||
],
|
||||
|
|
|
|||
|
|
@ -31,7 +31,8 @@ return [
|
|||
'status' => 'Status',
|
||||
|
||||
'validations' => [
|
||||
'required' => 'Selecione CAPTCHA'
|
||||
'required' => 'Selecione CAPTCHA',
|
||||
'captcha' => 'Algo deu errado! Por favor, tente novamente.',
|
||||
]
|
||||
],
|
||||
],
|
||||
|
|
|
|||
|
|
@ -56,6 +56,12 @@
|
|||
</span>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
|
||||
{!! Captcha::render() !!}
|
||||
|
||||
</div>
|
||||
|
||||
{!! view_render_event('bagisto.shop.customers.forget_password_form_controls.after') !!}
|
||||
|
||||
<button class="theme-btn" type="submit">
|
||||
|
|
@ -69,3 +75,9 @@
|
|||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('scripts')
|
||||
|
||||
{!! Captcha::renderJS() !!}
|
||||
|
||||
@endpush
|
||||
Loading…
Reference in New Issue