0

I've got a simple CRUD application in which is possible to add users, through a form, the ideal flow is

  • an admin fills the form with user name and password
  • an email is sent to the user with a link to set the password
  • the user is logged in

Now at the end of the day what I really want is that the PasswordBroker does, but instead to send the emails.passsowrd view I want a different one, and the rest of the logic can be the same

Is there an easy way so create a valid isntace of the passwordBroker and passing a different view?

the property emailWiew is protected so I cannot override it, I tried to create a new instance out of the IoC

$tokens = $this->app['auth.password.tokens'];

$users = $this->app['auth']->driver()->getProvider();

$view = "emails.createPassword";

$password =  new PasswordBroker(
    $tokens, $users, $this->app['mailer'], $view
);
dd($users->retrieveByCredentials(["email@user.com"])); //i get null and the user email is valid

$response = $password->sendResetLink(["email@user.com"], function (Message $message) {
    $message->subject("Set your password");
});
dd($response); // I get "passwords.user" wich is an error

but when I pass the email address I get an invalid user error

any idea?

4

1 回答 1

0

问题是您没有提供检索凭据的密钥,因此它试图在用户表中以“0”的名称获取一个字段。使用以下内容,它将起作用:

$response = $password->sendResetLink(
    ["email" => "email@user.com"], 
    function (Message $message) {
        $message->subject("Set your password");
});
于 2015-10-06T12:16:25.977 回答