/** * 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(); }
/** * 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; }
private function authenticate($login, $tokenAuth) { $this->auth->setLogin($login); $this->auth->setTokenAuth($tokenAuth); return $this->auth->authenticate(); }