【发布时间】: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