/**
  * 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"));
 }
 /**
  * Get info on the current user via the Sonar API.
  * @return Contact
  */
 private function getContact()
 {
     if (!Cache::tags("profile.details")->has(get_user()->contact_id)) {
         $contactController = new ContactController();
         $contact = $contactController->getContact(get_user()->contact_id, get_user()->account_id);
         Cache::tags("profile.details")->put(get_user()->contact_id, $contact, 10);
     }
     return Cache::tags("profile.details")->get(get_user()->contact_id);
 }