vendredi 21 août 2015

Laravel 5 - How to allow admin user to request password reset for any user

I am building a system admin tool in Laravel 5 using the sleeping-own/admin package. One of the requirements is to allow admin users to initiate the password reset process for any given user. Essentially just to fire off a password reset link in an email to the selected users email address.

I have tried various approaches using the built in PasswordController but everything is built to reset the password of the currently authenticated user which will obviously always be the admin user.

Any pointers greatly appreciated. Sample code below giving "None static method" error.

Route::get('user/{id}/password', [
'as' => 'admin.user.password',
function ($id) {

    $user = \App\User::find($id);

    $response = Illuminate\Contracts\Auth\PasswordBroker::sendResetLink($user, function($message)
    {
        $message->subject('Password Reminder');
    });

    switch ($response)
    {
        case PasswordBroker::RESET_LINK_SENT:
            return ['status'=> trans($response)];

        case PasswordBroker::INVALID_USER:
            return ['email' => trans($response)];
    }
    return ['success' => 'Password reset email sent.'];

}

]);



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1JaB5Oh
via IFTTT

Aucun commentaire:

Enregistrer un commentaire