/**
  * Update the user's password.
  *
  * @param  \App\Http\Requests\UpdatePasswordRequest  $request
  * @return \Illuminate\Http\Response
  */
 public function updatePassword(UpdatePasswordRequest $request)
 {
     if (!Hash::check($request->input('old_password'), $this->currentUser->password)) {
         return back()->withErrors('Password does not match.');
     }
     $this->currentUser->password = Hash::make($request->input('password'));
     $this->currentUser->save();
     flash()->success('Your password has been changed!');
     return back();
 }
예제 #2
0
 public function updatePassword(UpdatePasswordRequest $request)
 {
     $credentials = ['username' => Auth::user()->username, 'password' => $request->input('old_password')];
     if (Auth::attempt($credentials)) {
         $input['password'] = bcrypt($request->input('old_password'));
         $user = User::findOrFail(Auth::user()->id);
         $user->update($input);
         session()->flash('flash_message', 'Successfully update password.');
         return redirect()->route('profile');
     } else {
         session()->flash('flash_message', 'The Old Password is Wrong.');
         return redirect()->route('profile-edit-password');
     }
 }
 /**
  * Update the user password
  * @param UpdatePasswordRequest $request
  * @return $this|\Illuminate\Http\RedirectResponse
  */
 public function updatePassword(UpdatePasswordRequest $request)
 {
     //Validate that the current password is correct before allowing an update
     $accountAuthenticationController = new AccountAuthenticationController();
     try {
         $accountAuthenticationController->authenticateUser(get_user()->username, $request->input('current_password'));
     } catch (Exception $e) {
         return redirect()->back()->withErrors(trans("errors.currentPasswordInvalid"));
     }
     $contact = $this->getContact();
     $contactController = new ContactController();
     try {
         $contactController->updateContactPassword($contact, $request->input('new_password'));
     } catch (Exception $e) {
         return redirect()->back()->withErrors($e->getMessage());
     }
     return redirect()->action("ProfileController@show")->with('success', trans("profile.passwordUpdated"));
 }