/**
  * Update an password change.
  * Responds to requests to PATCH /profile/password
  *
  * @param  \App\Http\Requests\UpdatePasswordRequest  $request
  * @return Response
  */
 public function updatePassword(UpdatePasswordRequest $request)
 {
     $errors = array();
     if (Auth::attempt(['email' => Auth::user()->email, 'password' => $request->get('current_password')])) {
         $user = Auth::user();
         $user->update(['password' => bcrypt($request->get('new_password'))]);
         return back()->with('success', 'Changes updated successfully!');
     } else {
         $errors = array_add($errors, 'current_password', 'Your current password is incorrect.');
         return back()->withErrors($errors)->withInput();
     }
 }
Example #2
0
 public function updatePassword(\App\Http\Requests\UpdatePasswordRequest $request)
 {
     $this->user->updatePassword($request->get('password'));
     // flash successfull message
     $request->session()->flash('success', 'Successfully update password');
     // return back to previous
     return redirect()->route('home');
 }
 public function updatePassword(Requests\UpdatePasswordRequest $request)
 {
     //id ni nakalogin na user
     $userID = \Auth::user()->id;
     $hashed_old_password = DB::table('users')->where('id', $userID)->value('password');
     //valid na yung ipampapalit na password,
     //checheck nalang kung yung old password nya ay tama
     if (\Hash::check($request->get('old_password'), $hashed_old_password)) {
         //old password exists!
         $user = DB::table('users')->where('id', $userID)->update(['password' => bcrypt($request->get('password'))]);
         flash()->overlay('Password changed!', 'Success!');
         return redirect()->back();
         //return view('user.profile');
     } else {
         return back()->withInput();
     }
 }