<commit_before><?php

namespace ChurchCRM\Authentication\AuthenticationProviders {

    use ChurchCRM\Utils\LoggerUtils;
    use ChurchCRM\UserQuery;
    use ChurchCRM\Authentication\Requests\APITokenAuthenticationRequest;
    use ChurchCRM\Authentication\AuthenticationResult;
    use ChurchCRM\Authentication\Requests\AuthenticationRequest;
    use ChurchCRM\Exceptions\NotImplementedException;

class APITokenAuthentication implements IAuthenticationProvider
    {

        /***
         * @var ChurchCRM\User
         */
        private $currentUser;

        public function GetCurrentUser()
        {
          return $this->currentUser;
        }

        public function Authenticate(AuthenticationRequest $AuthenticationRequest) {
            if (! $AuthenticationRequest instanceof APITokenAuthenticationRequest ) {
                throw new \Exception ("Unable to process request as APITokenAuthenticationRequest");
            }
            $authenticationResult = new AuthenticationResult();
            $authenticationResult->isAuthenticated = false;
            $authenticationResult->preventRedirect = true;
            $this->currentUser = UserQuery::create()->findOneByApiKey($AuthenticationRequest->APIToken);

            if (!empty($this->currentUser)) {
                LoggerUtils::getAuthLogger()->info(gettext("User authenticated via API Key: ") . $this->currentUser->getName());
                $authenticationResult->isAuthenticated = true;
            } else {
                LoggerUtils::getAuthLogger()->warning(gettext("Unsuccessful API Key authentication attempt"));
            }
            return $authenticationResult;
        }

        public function ValidateUserSessionIsActive($updateLastOperationTimestamp) : AuthenticationResult
        {
            // APITokens are sessionless, so just always say false.
            $authenticationResult = new AuthenticationResult();
            $authenticationResult->isAuthenticated = false;
            return $authenticationResult;
        }

        public function EndSession() {
            $this->currentUser = null;
        }

        public function GetPasswordChangeURL() {
            throw new NotImplementedException();
        }
    }

}
<commit_msg>move log to debug from info<commit_after><?php

namespace ChurchCRM\Authentication\AuthenticationProviders {

    use ChurchCRM\Utils\LoggerUtils;
    use ChurchCRM\UserQuery;
    use ChurchCRM\Authentication\Requests\APITokenAuthenticationRequest;
    use ChurchCRM\Authentication\AuthenticationResult;
    use ChurchCRM\Authentication\Requests\AuthenticationRequest;
    use ChurchCRM\Exceptions\NotImplementedException;

class APITokenAuthentication implements IAuthenticationProvider
    {

        /***
         * @var ChurchCRM\User
         */
        private $currentUser;

        public function GetCurrentUser()
        {
          return $this->currentUser;
        }

        public function Authenticate(AuthenticationRequest $AuthenticationRequest) {
            if (! $AuthenticationRequest instanceof APITokenAuthenticationRequest ) {
                throw new \Exception ("Unable to process request as APITokenAuthenticationRequest");
            }
            $authenticationResult = new AuthenticationResult();
            $authenticationResult->isAuthenticated = false;
            $authenticationResult->preventRedirect = true;
            $this->currentUser = UserQuery::create()->findOneByApiKey($AuthenticationRequest->APIToken);

            if (!empty($this->currentUser)) {
                LoggerUtils::getAuthLogger()->debug(gettext("User authenticated via API Key: ") . $this->currentUser->getName());
                $authenticationResult->isAuthenticated = true;
            } else {
                LoggerUtils::getAuthLogger()->warning(gettext("Unsuccessful API Key authentication attempt"));
            }
            return $authenticationResult;
        }

        public function ValidateUserSessionIsActive($updateLastOperationTimestamp) : AuthenticationResult
        {
            // APITokens are sessionless, so just always say false.
            $authenticationResult = new AuthenticationResult();
            $authenticationResult->isAuthenticated = false;
            return $authenticationResult;
        }

        public function EndSession() {
            $this->currentUser = null;
        }

        public function GetPasswordChangeURL() {
            throw new NotImplementedException();
        }
    }

}

{'fraction_non_alphanumeric': 0.08386953627690259, 'fraction_numerical': 0.0, 'mean_word_length': 2.647249190938511, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1119354', 'n_tokens_mistral': 1034, 'n_tokens_neox': 1019, 'n_words': 209}