我想laravel 3场(OLD_PASSWORD,NEW_PASSWORD,confirm_password)创建形式5.更改密码的用户laravel 5.3
查看
旧密码: {!! Form::password('old_password',['class' => 'form-control']) !!}
新密码: {!! Form::password('password',['class' => 'form-control']) !!}
确认新密码:{!! Form::password('verify_password',['class' => 'form-control']) !!}
控制器的时候,用户注册
public function postRegister(Request $request)
{
$rules = [
'email' => 'required|email|unique:users',
'confirm_email' => 'required|same:email',
'password' => 'required|min:8|regex:/^(?=\S*[a-z])(?=\S*[[email protected]#$&*])(?=\S*[A-Z])(?=\S*[\d])\S*$/',
'verify_password' => 'required|same:password',
];
$messages = [
'email.required' => 'email tidak boleh kosong',
'password.required' => 'password tidak boleh kosong',
'password.min' => 'Password harus minimal 8 karakter',
'password.regex' => 'Format password harus terdiri dari kombinasi huruf besar, angka dan karakter spesial (contoh:[email protected]#$%^&*?><).',
'verify_password.required' => 'Verify Password tidak boleh kosong',
'email.email' => 'Format Email tidak valid',
'email.unique' => 'Email yang anda masukkan telah digunakan',
'verify_password.same' => 'Password tidak sama!',
];
$this->validate($request,$rules,$messages);
$newUser = $this->user->create([
'email' => $request->email,
'password' => \Hash::make($request->password),
]);
$this->activationService->sendActivationMail($newUser);
return redirect('/account/login')->with('success', 'Check your email');
}
我在laravel新的,我读过一些类似的问题在计算器更改密码,但它并没有帮助我。
我应该如何在我的控制器中编写代码来更改密码用户? 在此先感谢。
您可以使用内置的passwordcontroller。 –
如果你想手动操作,你必须研究这个'vendor \ laravel \ framework \ src \ Illuminate \ Foundation \ Auth \ ResetsPasswords \ PasswordController.php'页面。 – Manish
选中此https://www.5balloons.info/setting-up-change-password-with-laravel-authentication/ – jpussacq