Ejemplo n.º 1
0
 /**
  * Update the password of a User.
  *
  * @param  UserRequest  $request
  * @param  int  $uid
  * @return Response
  */
 public function updatePassword(UpdatePasswordRequest $request, $uid)
 {
     try {
         // Make sure the user updating the password is the user themselves
         // or a System Administrator.
         $initiator = $request->header('ID');
         if ($initiator != $uid) {
             return response()->error(403);
         }
         $user = Sentinel::findById($uid);
         if (!$user) {
             return response()->error(404, 'User Not Found');
         }
         // Verify that the old password matches their current password in
         // the database.
         $oldPassword = ['password' => $request->old_password];
         if (!Sentinel::validateCredentials($user, $oldPassword)) {
             return response()->error(422, 'Incorrect old password!');
         }
         // Change their password to the new password.
         $newPassword = ['password' => $request->new_password];
         Sentinel::update($user, $newPassword);
         return response()->success();
     } catch (Exception $e) {
         return response()->error();
     }
 }
Ejemplo n.º 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');
 }
 /**
  * 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();
 }
 /**
  * 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();
     }
 }
Ejemplo n.º 5
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"));
 }
Ejemplo n.º 7
0
 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();
     }
 }