我想改變密碼提醒行爲的方式。在Laravel中,一旦用戶重置密碼,password_reminders表中使用其令牌創建的行將被刪除。 我希望能夠做其他事情(將其設置爲使用等)。 我想知道的是如何擴展這種行爲。Laravel編輯密碼提醒行爲(不刪除密碼更改行)
在PasswordBroker的方法復位情況如下:(照亮/認證/提醒/ PasswordBroker.php)
public function reset(array $credentials, Closure $callback)
{
// If the responses from the validate method is not a user instance, we will
// assume that it is a redirect and simply return it from this method and
// the user is properly redirected having an error message on the post.
$user = $this->validateReset($credentials);
if (! $user instanceof RemindableInterface)
{
return $user;
}
$pass = $credentials['password'];
// Once we have called this callback, we will remove this token row from the
// table and return the response from this callback so the user gets sent
// to the destination given by the developers from the callback return.
call_user_func($callback, $user, $pass);
$this->reminders->delete($credentials['token']);
return self::PASSWORD_RESET;
}
現在在我的RemindersController我actullay調用門面密碼:
$response = Password::reset($credentials, function($user, $password)
{
$user->password = Hash::make($password);
$user->save();
});
如何創建PasswordBroker的擴展並從我的控制器調用它?我還必須創建一個新的服務提供商嗎? 所以編寫一個擴展PasswordBroker的新類,編寫一個新的服務提供者來擴展ReminderServiceProvider以及一個新的Facade,並在我的控制器中調用那個新Facade的新方法?這是正確的路嗎?
所以你認爲創建一個擴展passwordbroker.php的類,有一個重置方法,並通過命名空間調用該擴展類/方法driectly?沒有必要通過Facades?儘管它在應用程序級別上可用,但是我該怎麼做呢?創建該類併爲其提供服務提供者和門面? –
我更新了上面的答案。 – carousel
看起來很容易,當解釋這樣!我會給它一個歡呼聲。 –