/**
  * 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"));
 }
 /**
  * Authenticate against the Sonar API
  * @param AuthenticationRequest $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function authenticate(AuthenticationRequest $request)
 {
     if ($this->getThrottleValue("login", $this->generateLoginThrottleHash($request)) > 10) {
         return redirect()->back()->withErrors(trans("errors.tooManyFailedAuthenticationAttempts"));
     }
     $accountAuthenticationController = new AccountAuthenticationController();
     try {
         $result = $accountAuthenticationController->authenticateUser($request->input('username'), $request->input('password'));
         $request->session()->put('authenticated', true);
         $request->session()->put('user', $result);
     } catch (AuthenticationException $e) {
         $this->incrementThrottleValue("login", $this->generateLoginThrottleHash($request));
         $request->session()->forget('authenticated');
         $request->session()->forget('user');
         return redirect()->back()->withErrors(trans("errors.loginFailed"));
     }
     $this->resetThrottleValue("login", $this->generateLoginThrottleHash($request));
     return redirect()->action("BillingController@index");
 }