original_string: protected function authenticateAndRedirect($login, $password, $urlToRedirect = false, $passwordHashed = false)
      {
          Nonce::discardNonce('Login.login');
  
          $this->auth->setLogin($login);
          if ($passwordHashed === false) {
              $this->auth->setPassword($password);
          } else {
              $this->auth->setPasswordHash($password);
          }
  
          $this->sessionInitializer->initSession($this->auth);
  
          // remove password reset entry if it exists
          $this->passwordResetter->removePasswordResetInfo($login);
  
          if (empty($urlToRedirect)) {
              $redirect = Common::unsanitizeInputValue(Common::getRequestVar('form_redirect', false));
              $redirectParams = UrlHelper::getArrayFromQueryString(UrlHelper::getQueryFromUrl($redirect));
              $module = Common::getRequestVar('module', '', 'string', $redirectParams);
              // when module is login, we redirect to home...
              if (!empty($module) && $module !== 'Login' && $module !== Piwik::getLoginPluginName() && $redirect) {
                  $host = Url::getHostFromUrl($redirect);
                  $currentHost = Url::getHost();
                  $currentHost = explode(':', $currentHost, 2)[0];
  
                  // we only redirect to a trusted host
                  if (!empty($host) && !empty($currentHost) && $host == $currentHost && Url::isValidHost($host)
                  ) {
                      $urlToRedirect = $redirect;
                  }
              }
          }
  
          if (empty($urlToRedirect)) {
              $urlToRedirect = Url::getCurrentUrlWithoutQueryString();
          }
  
          Url::redirectToUrl($urlToRedirect);
      }
code: protected function authenticateAndRedirect($login, $password, $urlToRedirect = false, $passwordHashed = false)
      {
          Nonce::discardNonce('Login.login');
  
          $this->auth->setLogin($login);
          if ($passwordHashed === false) {
              $this->auth->setPassword($password);
          } else {
              $this->auth->setPasswordHash($password);
          }
  
          $this->sessionInitializer->initSession($this->auth);
  
          // remove password reset entry if it exists
          $this->passwordResetter->removePasswordResetInfo($login);
  
          if (empty($urlToRedirect)) {
              $redirect = Common::unsanitizeInputValue(Common::getRequestVar('form_redirect', false));
              $redirectParams = UrlHelper::getArrayFromQueryString(UrlHelper::getQueryFromUrl($redirect));
              $module = Common::getRequestVar('module', '', 'string', $redirectParams);
              // when module is login, we redirect to home...
              if (!empty($module) && $module !== 'Login' && $module !== Piwik::getLoginPluginName() && $redirect) {
                  $host = Url::getHostFromUrl($redirect);
                  $currentHost = Url::getHost();
                  $currentHost = explode(':', $currentHost, 2)[0];
  
                  // we only redirect to a trusted host
                  if (!empty($host) && !empty($currentHost) && $host == $currentHost && Url::isValidHost($host)
                  ) {
                      $urlToRedirect = $redirect;
                  }
              }
          }
  
          if (empty($urlToRedirect)) {
              $urlToRedirect = Url::getCurrentUrlWithoutQueryString();
          }
  
          Url::redirectToUrl($urlToRedirect);
      }
code_tokens: protected function authenticateAndRedirect ( $ login , $ password , $ urlToRedirect = false , $ passwordHashed = false ) { Nonce :: discardNonce ( 'Login.login' ) ; $ this -> auth -> setLogin ( $ login ) ; if ( $ passwordHashed === false ) { $ this -> auth -> setPassword ( $ password ) ; } else { $ this -> auth -> setPasswordHash ( $ password ) ; } $ this -> sessionInitializer -> initSession ( $ this -> auth ) ; // remove password reset entry if it exists $ this -> passwordResetter -> removePasswordResetInfo ( $ login ) ; if ( empty ( $ urlToRedirect ) ) { $ redirect = Common :: unsanitizeInputValue ( Common :: getRequestVar ( 'form_redirect' , false ) ) ; $ redirectParams = UrlHelper :: getArrayFromQueryString ( UrlHelper :: getQueryFromUrl ( $ redirect ) ) ; $ module = Common :: getRequestVar ( 'module' , '' , 'string' , $ redirectParams ) ; // when module is login, we redirect to home... if ( ! empty ( $ module ) && $ module !== 'Login' && $ module !== Piwik :: getLoginPluginName ( ) && $ redirect ) { $ host = Url :: getHostFromUrl ( $ redirect ) ; $ currentHost = Url :: getHost ( ) ; $ currentHost = explode ( ':' , $ currentHost , 2 ) [ 0 ] ; // we only redirect to a trusted host if ( ! empty ( $ host ) && ! empty ( $ currentHost ) && $ host == $ currentHost && Url :: isValidHost ( $ host ) ) { $ urlToRedirect = $ redirect ; } } } if ( empty ( $ urlToRedirect ) ) { $ urlToRedirect = Url :: getCurrentUrlWithoutQueryString ( ) ; } Url :: redirectToUrl ( $ urlToRedirect ) ; }
docstring: Authenticate user and password.  Redirect if successful.
  
  @param string $login user name
  @param string $password plain-text or hashed password
  @param string $urlToRedirect URL to redirect to, if successfully authenticated
  @param bool $passwordHashed indicates if $password is hashed
  @return string failure message if unable to authenticate
docstring_tokens: Authenticate user and password . Redirect if successful .