Пример #1
0
 public function postChange(PasswordUpdateRequest $request)
 {
     if (\Hash::check($request->input('current_password'), auth()->user()->password)) {
         auth()->user()->password = crypt($request->input('new_password'));
         auth()->user()->save();
         flash()->success('Password updated successfully.');
         return \Redirect::back();
     }
     flash()->error('Please try again with correct current password.');
     return \Redirect::back();
 }
Пример #2
0
 public function updatePassword(PasswordUpdateRequest $request)
 {
     $user = \App\users::find(session('user')->userid);
     if ($user->password == $request->input('oldpassword')) {
         if ($request->input('oldpassword') != $request->input('password')) {
             $user->password = $request->input('oldpassword');
             $user->save();
             \Session::flash('message', 'Password changed Successfully!');
             \Session::flash('type', 'success');
             return view('user.password');
         } else {
             \Session::flash('message', 'New password and Old password cannot be the same');
             \Session::flash('type', 'danger');
             return view('user.password');
         }
     } else {
         \Session::flash('message', 'Old Password is not valid');
         \Session::flash('type', 'danger');
         return view('user.password');
     }
 }
 /**
  * Attempt to reset the password to a new value
  * @param PasswordUpdateRequest $request
  * @param $token
  * @return $this
  */
 public function updateContactWithNewPassword(PasswordUpdateRequest $request, $token)
 {
     if ($this->getThrottleValue("password_update", md5($request->getClientIp())) > 5) {
         return redirect()->back()->withErrors(trans("errors.tooManyFailedPasswordResets"));
     }
     $passwordReset = PasswordReset::where('token', '=', trim($token))->where('updated_at', '>=', Carbon::now("UTC")->subHours(24)->toDateTimeString())->first();
     if ($passwordReset === null) {
         $this->incrementThrottleValue("password_update", md5($token . $request->getClientIp()));
         return redirect()->action("AuthenticationController@showResetPasswordForm")->withErrors(trans("errors.invalidToken"));
     }
     if ($passwordReset->email != $request->input('email')) {
         $this->incrementThrottleValue("password_update", md5($token . $request->getClientIp()));
         return redirect()->back()->withErrors(trans("errors.invalidEmailAddress"));
     }
     $contactController = new ContactController();
     try {
         $contact = $contactController->getContact($passwordReset->contact_id, $passwordReset->account_id);
     } catch (Exception $e) {
         return redirect()->back()->withErrors(trans("errors.couldNotFindAccount"));
     }
     try {
         $contactController->updateContactPassword($contact, $request->input('password'));
     } catch (Exception $e) {
         return redirect()->back()->withErrors(trans("errors.failedToResetPassword"));
     }
     $passwordReset->delete();
     $this->resetThrottleValue("password_update", md5($token . $request->getClientIp()));
     return redirect()->action("AuthenticationController@index")->with('success', trans("register.passwordReset"));
 }
 public function postUpdatepassword(Requests\PasswordUpdateRequest $request)
 {
     $credentials = ['email' => Auth::user()->email, 'password' => $request->get('old_password')];
     if (\Auth::validate($credentials)) {
         $user = Auth::User();
         $user->password = Hash::make($request->password);
         $user->save();
         return Redirect::to('users/dashboard')->with('password-message', 'That updated for you.')->with('alert-class', 'alert-success')->withInput();
     }
     return Redirect::to('users/dashboard')->with('password-message', 'That not your password')->with('alert-class', 'alert-danger')->withInput();
 }