Edit password user login
public function updateProfile($id,Request $request){
$rules=[
'old_password'=>'required|old_password_validation',
'password'=>'required|confirmed',
'password_confirmation'=>'required'];
$pesan=[
'old_password_validation'=>'Pasword lama Salah',
];
Validator::extend('old_password_validation', function($field, $value, $parameters)
{
return Hash::check($value, Auth::User()->password);
});
$validator = Validator::make($request->all(), $rules, $pesan);
if ($validator->fails()){
return redirect()->back()
->withErrors($validator)
->withInput($request->except('password'));
}
$user=User::find($id);
$user->password=bcrypt($request->input('password'));
$user->nama=$request->input('nama');
$user->save();
return redirect()->back();
}
$rules=[
'old_password'=>'required|old_password_validation',
'password'=>'required|confirmed',
'password_confirmation'=>'required'];
$pesan=[
'old_password_validation'=>'Pasword lama Salah',
];
Validator::extend('old_password_validation', function($field, $value, $parameters)
{
return Hash::check($value, Auth::User()->password);
});
$validator = Validator::make($request->all(), $rules, $pesan);
if ($validator->fails()){
return redirect()->back()
->withErrors($validator)
->withInput($request->except('password'));
}
$user=User::find($id);
$user->password=bcrypt($request->input('password'));
$user->nama=$request->input('nama');
$user->save();
return redirect()->back();
}
0 comments: