【问题标题】:Laravel reset passwordLaravel 重置密码
【发布时间】:2016-08-22 09:09:56
【问题描述】:

我尝试重设密码,我的发帖路线转到 ->

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,那么,他有什么?

【问题讨论】:

  • 错误很明显,resetPassword方法需要一个Request对象,你发送的是User$password
  • 在reset函数检查trait ResetsPasswords,我也做了,我该怎么办?

标签: php laravel passwords reset


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-05-27
    • 2017-08-04
    • 2020-10-01
    • 1970-01-01
    • 2014-07-24
    • 2016-07-11
    • 2016-03-30
    • 2021-10-22
    相关资源
    最近更新 更多