<commit_before><?php
namespace Craft;

class TwoFactorAuthenticationPlugin extends BasePlugin
{
    public function getName()
    {
        return Craft::t('Two-Factor Authentication');
    }

    public function getVersion()
    {
        return '0.0.4';
    }

    public function getSchemaVersion()
    {
        return '0.0.1';
    }

    public function getDeveloper()
    {
        return 'Born05';
    }

    public function getDeveloperUrl()
    {
        return 'http://www.born05.com/';
    }

    public function getPluginUrl()
    {
        return 'https://github.com/born05/craft-twofactorauthentication';
    }

    public function getDocumentationUrl()
    {
        return $this->getPluginUrl() . '/blob/master/README.md';
    }

    public function getReleaseFeedUrl()
    {
        return 'https://raw.githubusercontent.com/born05/craft-twofactorauthentication/master/releases.json';
    }

    public function hasCpSection()
    {
        return true;
    }

    public function init()
    {
        parent::init();

        // Only allow users in the CP who are verified or don't use two-factor.
        $actionSegs = craft()->request->getActionSegments();
        if (
            craft()->request->isCpRequest() &&
            (
                craft()->request->getPath() !== '' &&
                $actionSegs !== array('users', 'login') &&
                $actionSegs !== array('users', 'logout') &&
                $actionSegs !== array('users', 'forgotpassword') &&
                $actionSegs !== array('users', 'sendPasswordResetEmail') &&
                $actionSegs !== array('users', 'setpassword') &&
                $actionSegs !== array('users', 'verifyemail') &&
                $actionSegs[0] !== 'update'
            ) &&
            !(
                $actionSegs[0] === 'twoFactorAuthentication' &&
                $actionSegs[1] === 'verify'
            )
        ) {
            $user = craft()->userSession->getUser();

            // Only redirect two-factor enabled users who aren't verified yet.
            if (isset($user) &&
                craft()->twoFactorAuthentication_verify->isEnabled($user) &&
                !craft()->twoFactorAuthentication_verify->isVerified($user)
            ) {
                craft()->userSession->logout(false);
                craft()->request->redirect(UrlHelper::getCpUrl());
            }
        }

        // Verify after login.
        craft()->on('userSession.onLogin', function(Event $event) {
            $user = craft()->userSession->getUser();

            if (isset($user) &&
                craft()->twoFactorAuthentication_verify->isEnabled($user) &&
                !craft()->twoFactorAuthentication_verify->isVerified($user)) {
                $url = UrlHelper::getActionUrl('twoFactorAuthentication/verify/login');
<commit_msg>#1 Whitelisted the getAuthTimeout call.<commit_after><?php
namespace Craft;

class TwoFactorAuthenticationPlugin extends BasePlugin
{
    public function getName()
    {
        return Craft::t('Two-Factor Authentication');
    }

    public function getVersion()
    {
        return '0.0.4';
    }

    public function getSchemaVersion()
    {
        return '0.0.1';
    }

    public function getDeveloper()
    {
        return 'Born05';
    }

    public function getDeveloperUrl()
    {
        return 'http://www.born05.com/';
    }

    public function getPluginUrl()
    {
        return 'https://github.com/born05/craft-twofactorauthentication';
    }

    public function getDocumentationUrl()
    {
        return $this->getPluginUrl() . '/blob/master/README.md';
    }

    public function getReleaseFeedUrl()
    {
        return 'https://raw.githubusercontent.com/born05/craft-twofactorauthentication/master/releases.json';
    }

    public function hasCpSection()
    {
        return true;
    }

    public function init()
    {
        parent::init();

        // Only allow users in the CP who are verified or don't use two-factor.
        $actionSegs = craft()->request->getActionSegments();
        if (
            craft()->request->isCpRequest() &&
            (
                craft()->request->getPath() !== '' &&
                $actionSegs !== array('users', 'login') &&
                $actionSegs !== array('users', 'logout') &&
                $actionSegs !== array('users', 'forgotpassword') &&
                $actionSegs !== array('users', 'sendPasswordResetEmail') &&
                $actionSegs !== array('users', 'setpassword') &&
                $actionSegs !== array('users', 'verifyemail') &&
                $actionSegs !== array('users', 'getAuthTimeout') &&
                $actionSegs[0] !== 'update'
            ) &&
            !(
                $actionSegs[0] === 'twoFactorAuthentication' &&
                $actionSegs[1] === 'verify'
            )
        ) {
            $user = craft()->userSession->getUser();

            // Only redirect two-factor enabled users who aren't verified yet.
            if (isset($user) &&
                craft()->twoFactorAuthentication_verify->isEnabled($user) &&
                !craft()->twoFactorAuthentication_verify->isVerified($user)
            ) {
                craft()->userSession->logout(false);
                craft()->request->redirect(UrlHelper::getCpUrl());
            }
        }

        // Verify after login.
        craft()->on('userSession.onLogin', function(Event $event) {
            $user = craft()->userSession->getUser();

            if (isset($user) &&
                craft()->twoFactorAuthentication_verify->isEnabled($user) &&
                !craft()->twoFactorAuthentication_verify->isVerified($user)) {
                $url = UrlHelper::getActionUrl('twoFactorAuthentication/verify/login');

{'fraction_non_alphanumeric': 0.14521739130434783, 'fraction_numerical': 0.00608695652173913, 'mean_word_length': 1.9906396255850234, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 51, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4917315', 'n_tokens_mistral': 1572, 'n_tokens_neox': 1490, 'n_words': 269}