lundi 2 octobre 2017

Add recaptcha to default Laravel Password Reset

I want to require the users of my Laravel 5.1 application to have finished a Google Recaptcha process, but I can't figure out how to safely modify the code that sends the reset password link.

The code that does this for me is the "postEmail()" function in the inherited trait "ResetsPassword". This is my entire PasswordController:

use App\Http\Controllers\Controller;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Contracts\Auth\PasswordBroker;
use Illuminate\Foundation\Auth\ResetsPasswords;

class PasswordController extends Controller {

use ResetsPasswords;

/**
 * Create a new password controller instance.
 *
 * @param  \Illuminate\Contracts\Auth\Guard  $auth
 * @param  \Illuminate\Contracts\Auth\PasswordBroker  $passwords
 * @return void
 */
public function __construct(Guard $auth, PasswordBroker $passwords)
{
    $this->auth = $auth;
    $this->passwords = $passwords;

    $this->middleware('guest');
}

}

As you can see, all the real methods are in the "ResetsPasswords" trait which is in a vendor file so I don't want to modify it directly. How do I modify the "postEmail()" function in the inherited trait safely in my PasswordsController?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire