3
votes

I have a Laravel 5.4 application and I have a view in my admin area that allows me to see all users.

I want to create a function that allows me to click a button in the back end that automates the process of sending the default Laravel password reset functionality.

In my view I have the following:

<table class="table table-hover">
                        <thead>
                            <th>#</th>
                            <th>Company</th>
                            <th>Name</th>
                            <th>Email Address</th>
                            <th>Action</th>
                        </thead>
                        <tbody>
                            @foreach(\App\User::all() as $c)
                                <tr>
                                    <td>{{ $c->id }}</td>
                                    <td>{{ $c->company->company_name }}</td>
                                    <td>{{ $c->name }}</td>
                                    <td>{{ $c->email }}</td>
                                    <td><a href="/admin/user/{{ $c->id }}/password/reset">Password Reset</a></td>
                                </tr>
                            @endforeach
                        </tbody>
                    </table>

On the link click for resetting the password this currently via my routes hits the following function

public function passwordReset($id)
    {

        $user = User::FindOrFail($id);

        Password::sendResetLink($user->email);

    }

I'm not to familiar with Laravels default password reset functionality so I'm probably way off but I get the following error:

Argument 1 passed to Illuminate\Auth\Passwords\PasswordBroker::sendResetLink() must be of the type array, string given,

1
You need to pass in an array of credentials, not a string.Ian
Thanks @Ian out of interest if this is a send password reset function why would I need to pass the password? surely this is being reset by the user?Dev.Wol
You don't need to pass the password.Ian

1 Answers

10
votes

You need to send an array with email as key:

Password::sendResetLink(['email' => $user->email]);