Laravel 4.2:Ollieread MultiAuth提醒问题

时间:2015-09-08 19:15:18

标签: laravel authentication laravel-4

我正在尝试第一次为我的L-4.2项目整合multiauth。一切似乎工作正常,但提醒不起作用。当我在密码/提醒页面输入电子邮件地址并提交时,它会给我一个错误:

  

参数1传递给Ollieread \ Multiauth \ Reminders \ PasswordBrokerManager :: __ construct()必须是Ollieread \ Multiauth \ Reminders \ ReminderRepositoryInterface的实例,给出的Illuminate \ Auth \ Reminders \ DatabaseReminderRepository实例,在D中调用:...第59行的。\ vendor \ ollieread \ multiauth \ src \ Ollieread \ Multiauth \ Reminders \ ReminderServiceProvider.php

您可以在此处查看完整的错误详情:http://awesomescreenshot.com/08a57ye350

模型

use Illuminate\Auth\UserTrait;
use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableTrait;
use Illuminate\Auth\Reminders\RemindableInterface;

class Admin extends Eloquent implements UserInterface, RemindableInterface {

    use UserTrait, RemindableTrait;

    /**
     * The database table used by the model.
     *
     * @var string
     */
    protected $table = 'admins';

    /**
     * The attributes excluded from the model's JSON form.
     *
     * @var array
     */
    protected $hidden = array('password', 'remember_token');

    // fillable array
    protected $fillable = array('name', 'email', 'password');

    // validation rules
    public static $rules = array(
        'name'                      => 'required|min:2', // alpha = only alphabets
        'email'                     => 'required|email|unique:admins', // unique in admins table
        'password'                  => 'required|between:8,20|confirmed',
        'password_confirmation'     => 'required|between:8,20'
    );
}

AdminRemindersController

class AdminRemindersController extends Controller {

    /**
     * Display the password reminder view.
     *
     * @return Response
     */
    public function getRemind()
    {
        return View::make('admin.password.remind');
    }

    /**
     * Handle a POST request to remind a user of their password.
     *
     * @return Response
     */
    public function postRemind()
    {
        $response = Password::admin()->remind(Input::only('email'), function($message)
        {
            $message->subject('Password Reminder');
        });

        switch ($response)
        {
            case Password::INVALID_USER:
                return Redirect::back()
                    ->with('message', Lang::get($response))
                    ->with('message-type', 'alert-danger');

            case Password::REMINDER_SENT:
                return Redirect::back()
                    ->with('message', Lang::get($response))
                    ->with('message-type', 'alert-success');
        }
    }

    /**
     * Display the password reset view for the given token.
     *
     * @param  string  $token
     * @return Response
     */
    public function getReset($token = null)
    {
        if (is_null($token)) App::abort(404);

        return View::make('admin.password.reset')->with('token', $token);
    }

    /**
     * Handle a POST request to reset a user's password.
     *
     * @return Response
     */
    public function postReset()
    {
        $credentials = Input::only(
            'email', 'password', 'password_confirmation', 'token'
        );

        $response = Password::admin()->reset($credentials, function($user, $password)
        {
            $user->password = Hash::make($password);

            $user->save();
        });

        switch ($response)
        {
            case Password::INVALID_PASSWORD:
            case Password::INVALID_TOKEN:
            case Password::INVALID_USER:
                return Redirect::back()->with('error', Lang::get($response));

            case Password::PASSWORD_RESET:
                return Redirect::to('admin.login')
                            ->with('message', 'Password changed successfully.')
                            ->with('message-type', 'alert-success');
        }
    }

}

请帮忙。

1 个答案:

答案 0 :(得分:0)

好的,我发现了这个问题。我不得不用Multi Auth服务提供商替换默认的Auth服务提供商。在我的情况下,我确实更换了以下服务提供商的提醒:

'Illuminate\Auth\Reminders\ReminderServiceProvider',

替换为:

'Ollieread\Multiauth\Reminders\ReminderServiceProvider'

错误现在消失了。