【发布时间】:2014-02-09 22:46:38
【问题描述】:
我想更改密码提醒的行为方式。在 Laravel 中,一旦用户重置密码,在 password_reminders 表中创建的带有他们的令牌的行就会被删除。 我希望能够做其他事情(将其设置为已使用等)。 我想知道的是如何扩展这种行为。
PasswordBroker中的重置方法如下:(Illuminate/Auth/reminders/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 中,我正在调用外观密码:
$response = Password::reset($credentials, function($user, $password)
{
$user->password = Hash::make($password);
$user->save();
});
如何创建 PasswordBroker 的扩展并从我的控制器调用它?我是否也必须创建一个新的服务提供者? 所以编写一个扩展 PasswordBroker 的新类,编写一个扩展 ReminderServiceProvider 的新服务提供程序以及一个新的 Facade 并在我的控制器中调用该新 Facade 的新方法?这是正确的方法吗?
【问题讨论】:
标签: php laravel laravel-4 ioc-container