For security reasons, in one of the applications that I'm building, whenever the user's password is changed it must be notified. To meet this goal I overwritten the method resetPassword
of class ResetsPasswords
in my ResetPasswordController
as below:
<?php
namespace App\Http\Controllers\Auth;
//...
class ResetPasswordController extends Controller
{
//...
/**
* Sobrescreve o método padrão para que seja enviada uma notificação de alteração de senha
*
* @param \Illuminate\Contracts\Auth\CanResetPassword $user
* @param string $password
* @return void
*/
protected function resetPassword($user, $password)
{
$user->password = Hash::make($password);
$user->setRememberToken(Str::random(60));
$user->save();
event(new PasswordReset($user));
$this->guard()->login($user);
$user->notify(new AlteracaoSenha());
}
}
As you can see, I had to rewrite the whole method to add only one line. Is it possible to do something less around the world? Such as:
protected function resetPassword($user, $password)
{
parent::resetPassword($user, $password);
$user->notify(new AlteracaoSenha());
}
I understand that this example does not work there, it was just cited as an example of what I want to do.
Note: I use Laravel 5.6