Inheritance: implements Piwik\Auth
Ejemplo n.º 1
0
 /**
  * Authenticates user
  *
  * @return \Piwik\AuthResult
  */
 public function authenticate()
 {
     $httpLogin = $this->getHttpAuthLogin();
     if (!empty($httpLogin)) {
         $user = $this->userModel->getUser($httpLogin);
         if (empty($user)) {
             return new AuthResult(AuthResult::FAILURE, $httpLogin, null);
         }
         $code = !empty($user['superuser_access']) ? AuthResult::SUCCESS_SUPERUSER_AUTH_CODE : AuthResult::SUCCESS;
         return new AuthResult($code, $httpLogin, $user['token_auth']);
     }
     return parent::authenticate();
 }
Ejemplo n.º 2
0
 /**
  * Authenticate user and password.  Redirect if successful.
  *
  * @param string $login user name
  * @param string $password md5 password
  * @param bool $rememberMe Remember me?
  * @param string $urlToRedirect URL to redirect to, if successfully authenticated
  * @return string failure message if unable to authenticate
  */
 protected function authenticateAndRedirect($login, $password, $rememberMe, $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, $rememberMe);
     // remove password reset entry if it exists
     $this->passwordResetter->removePasswordResetInfo($login);
     if (empty($urlToRedirect)) {
         $urlToRedirect = Url::getCurrentUrlWithoutQueryString();
     }
     Url::redirectToUrl($urlToRedirect);
 }
 /**
  * Authenticates user
  *
  * @return AuthResult
  */
 public function authenticate()
 {
     $authResult = parent::authenticate();
     // if authentication was correct, check if an auth code is required
     if ($authResult->wasAuthenticationSuccessful()) {
         $this->setLogin($authResult->getIdentity());
         $storage = new Storage($authResult->getIdentity());
         $this->validateAuthCode();
         // if Google Authenticator is disabled, or user already validated with auth code
         if (!$storage->isActive() || $this->getValidatedWithAuthCode()) {
             return $authResult;
         }
         $authResult = new AuthResult(self::AUTH_CODE_REQUIRED, $this->login, $this->token_auth);
     }
     return $authResult;
 }
Ejemplo n.º 4
0
 private function authenticate($login, $tokenAuth)
 {
     $this->auth->setLogin($login);
     $this->auth->setTokenAuth($tokenAuth);
     return $this->auth->authenticate();
 }