2016-08-22 164 views
0

我试图做一个重置密码,我的帖子路线去 - >Laravel重置密码

public function ResetPassword(Request $request) { 
    $template_data = [ 
     'template' => $this->template->ConstructArrayTemplate(), 
     'token'  => htmlspecialchars($request->get('token')), 
     'email'  => htmlspecialchars($request->get('email')) 
    ];    

    $rules = [ 
     'token'     => 'required', 
     'email'     => 'required|email', 
     'password'    => 'required|between:6,100|confirmed|passpower' 
    ]; 

    $validator = Validator::make($request->all(), $rules); 
    $errors = $this->sortErrors ($validator, array('token','email','password')); 

    if ($errors) { 
     $template_data [ 'Errs' ] = $errors; 
     $template_data [ 'template' ] [ 'page_name' ] = 'Reset password'; 

     return view('reset_password', $template_data); 
    }   

    $credentials = $request->only('email', 'password', 'password_confirmation', 'token'); 

    $broker = $this->getBroker(); 

    $stats = Password::broker($broker)->reset($credentials, function ($user, $password) { 
     $this->resetPassword($user, $password); 
    }); 

    switch ($stats) { 
     case Password::PASSWORD_RESET: 
      return rediect(''); 
     default: 
      return view('404'); 
    }    
} 

真正的错误来自:

$this->resetPassword($user, $password); 

ErrorException in AccountSign.php line 109: Argument 1 passed to App\Http\Controllers\AccountSign::ResetPassword() must be an instance of Illuminate\Http\Request, instance of App\User given, called in C:\XAMPP\htdocs\app\Http\Controllers\AccountSign.php on line 137 and defined 

我用ResetsPasswords,所以,他有?

+3

的错误是很清晰,'resetPassword'方法需要一个'Request'对象,你是在复位功能发送'User'和'$ password' –

+0

检查特质ResetsPasswords,我也一样,我应该怎么办呢? –

回答

0

$ this-> resetPassword($ user,$ password);是对密码代理回调的无效调用,因为您再次调用该操作,并且您的操作仅接受请求对象,而不接受用户和密码。