В настоящее время логика сброса пароля заключается в том, что пользователь должен указать действующий/зарегистрированный адрес электронной почты, чтобы получить сообщение электронной почты для восстановления пароля.
В моем случае я не хочу проверять, зарегистрирована ли электронная почта или нет из соображений безопасности, и я хочу просто выполнить внутреннюю проверку и сообщить пользователю, что «Если он предоставил зарегистрированную электронную почту, он должен получить электронное письмо для восстановления в ближайшее время».
То, что я сделал для этого, редактируется в методе vendor\laravel\framework\src\Illuminate\Auth\Passwords\PasswordBroker.php
sendResetLink()
из этого:
/**
* Send a password reset link to a user.
*
* @param array $credentials
* @return string
*/
public function sendResetLink(array $credentials)
{
// First we will check to see if we found a user at the given credentials and
// if we did not we will redirect back to this current URI with a piece of
// "flash" data in the session to indicate to the developers the errors.
$user = $this->getUser($credentials);
if (is_null($user)) {
return static::INVALID_USER;
}
// Once we have the reset token, we are ready to send the message out to this
// user with a link to reset their password. We will then redirect back to
// the current URI having nothing set in the session to indicate errors.
$user->sendPasswordResetNotification(
$this->tokens->create($user)
);
return static::RESET_LINK_SENT;
}
к этому:
/**
* Send a password reset link to a user.
*
* @param array $credentials
* @return string
*/
public function sendResetLink(array $credentials)
{
// First we will check to see if we found a user at the given credentials and
// if we did not we will redirect back to this current URI with a piece of
// "flash" data in the session to indicate to the developers the errors.
$user = $this->getUser($credentials);
// if (is_null($user)) {
// return static::INVALID_USER;
// }
// Once we have the reset token, we are ready to send the message out to this
// user with a link to reset their password. We will then redirect back to
// the current URI having nothing set in the session to indicate errors.
if(!is_null($user)) {
$user->sendPasswordResetNotification(
$this->tokens->create($user)
);
}
return static::RESET_LINK_SENT;
}
Этот жестко запрограммированный вариант — не лучшее решение, потому что он исчезнет после обновления.. поэтому я хотел бы знать, как я могу расширить или реализовать это изменение в рамках проекта в папке App
, чтобы сохранить это изменение. всегда?
P.S. Я пробовал упомянутое здесь решение: Настройка брокера паролей Laravel 5.3, но это не помогло не работает .. также отличается дерево каталогов, и я не мог понять, куда поместить новый файл PasswordBroker.php
.
Заранее спасибо!