dimanche 4 septembre 2016

Laravel 5.1 sarav multiauth ResetsPasswords method postEmail not work

I'm using sarav/multiauth and I'm trying to use the method postEmail.

But this would not be working for me. The problem is that this method find the user in other model and not the model I need.

I'm define the auth.php

'multi' => [
    'admin' => [
        'driver' => 'eloquent',
        'model'  => Infinito\Models\Admin::class,
        'table'  => 'admins'
    ],
    'user' => [
        'driver' => 'eloquent',
        'model'  => Infinito\Models\User::class,
        'table'  => 'users'
    ]
],

PasswordController.php

use Sarav\Multiauth\Foundation\ResetsPasswords;

public function __construct()
{
    $this->user = "user";
}

But when I call the method postEmail in vendor sarav ResetsPasswords.php

/**
 * Send a reset link to the given user.
 *
 * @param  \Illuminate\Http\Request  $request
 * @return \Illuminate\Http\Response
 */
public function postEmail(Request $request)
{
    $this->validate($request, ['email' => 'required|email']);

    $app = app();

    $class = str_ireplace('App\Http\Controllers\\', '', get_called_class());

    view()->composer($app->config['auth.password.email'], function($view) use ($class) {
        $view->with('action', $class.'@getReset');
    });

    $response = Password::sendResetLink($request->only('email'), function (Message $message) {
        $message->subject($this->getEmailSubject());
    });

    switch ($response) {
        case Password::RESET_LINK_SENT:
            return redirect()->back()->with('status', trans($response));

        case Password::INVALID_USER:
            return redirect()->back()->withErrors(['email' => trans($response)]);
    }
}

I get response INVALID_USER. If I send an existing user in the admins table it works, but not is the model I need. If i send an existing user in the users table $response is INVALID_USER.

I could see that the problem is here but I have no idea because.

$response = Password::sendResetLink($request->only('email'), function (Message $message) {
        $message->subject($this->getEmailSubject());
    });

Any idea?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire