I'm having trouble creating a method that will allow me to provide a password change form for logged-in users. I would like to use the methods of the class: App \ Http \ Controllers \ Auth \ ResetPasswordController.
Currently I have a view with 3 fields, they are:
- current_password
- new_password
- nova_senha_confirmation
In the controller I have a method with the code to validate the data received and persist in the database:
$this->validate($request, [
'senha_atual' => 'required|min:8',
'nova_senha' => 'required|min:8|confirmed']);
if (!Hash::check($request->senha_atual, Auth::user()->password))
{
return redirect('/painel/alterarSenha')->withErrors(['senha_atual' => 'Senha incorreta'])->withInput();;
}
$resultado = $request->user()->fill([
'password' => Hash::make($request->input('nova_senha'))
])->save();
if($resultado)
{
return redirect('/painel')->with(['success' => 'Senha alterada com sucesso!']);
}
But as I already mentioned, I would like to use the methods of controlling ResetPasswordController that extends from Illuminate \ Foundation \ Auth \ ResetsPasswords, even to follow a solid approach and without duplication of code.