<commit_before><?php
App::uses('AppController', 'Controller');
class AdminAppController extends AppController {

    public $backendPluginName = null;
    public $backendPluginNameUnderscored = null;
    public $redirectUrl = null;

	public $helpers = array('Form', 'Html', 'Js', 'Session', 'Time');
	public $components = array(
        'Session',
        'Auth',
        'RequestHandler',
        'Paginator'
    );

    public function __construct($request = null, $response = null) {
        parent::__construct($request, $response);
        $this->backendPluginName = $this->plugin;
        $this->backendPluginNameUnderscored = Inflector::underscore($this->backendPluginName);
        $this->helpers[] = $this->backendPluginName . '.ExtendedForm';
        $this->set('backendPluginName', $this->backendPluginName);
        $this->set('backendPluginNameUnderscored', $this->backendPluginNameUnderscored);
    }

	public function beforeFilter() {
        //remove this block after you created the first user
        $this->Auth->allow();
        return;
        //end remove this block after you created the first user
		$this->Auth->authorize = array('Controller');
		$this->Auth->authenticate = array('Form' => array(
                'fields' => array('username' => 'email')
            )
        );
        $this->Auth->flash = array('element' => 'default', 'key' => 'auth', 'params' => array('class' => 'alert'));
        $this->Auth->loginAction = array('controller' => $this->backendPluginNameUnderscored . '_users', 'action' => 'login', 'plugin' => $this->backendPluginNameUnderscored);
        $this->Auth->logoutRedirect = array('controller' => 'pages', 'action' => 'display', 'home', 'plugin' => false);
        $this->Auth->loginRedirect = array('controller' => $this->backendPluginNameUnderscored . '_pages', 'action' => 'display', 'home', 'plugin' => Inflector::underscore($this->backendPluginName));
        if(!empty($this->request->query['redirect'])) {
            if(!empty($this->request->base) && strpos($this->request->query['redirect'], $this->request->base) === 0) {
                $this->request->query['redirect'] = substr($this->request->query['redirect'], strlen($this->request->base));
            }
            $this->redirectUrl = $this->request->query['redirect'];
        } else {
            if($this->request->action == 'index' && !$this->request->is('ajax')) {
                $this->redirectUrl = '/' . $this->request->url;
            } else {
                $this->redirectUrl = $this->referer(array('action' => 'index'), true);
            }
        }
	}

	public function beforeRender() {
		$this->set('redirectUrl', $this->redirectUrl);
	}

	public function isAuthorized($user = null) {
        if(!empty($user)) {
            return true;
        }
    }
}

<commit_msg>moved redirect block to top of beforeFilter function<commit_after><?php
App::uses('AppController', 'Controller');
class AdminAppController extends AppController {

    public $backendPluginName = null;
    public $backendPluginNameUnderscored = null;
    public $redirectUrl = null;

	public $helpers = array('Form', 'Html', 'Js', 'Session', 'Time');
	public $components = array(
        'Session',
        'Auth',
        'RequestHandler',
        'Paginator'
    );

    public function __construct($request = null, $response = null) {
        parent::__construct($request, $response);
        $this->backendPluginName = $this->plugin;
        $this->backendPluginNameUnderscored = Inflector::underscore($this->backendPluginName);
        $this->helpers[] = $this->backendPluginName . '.ExtendedForm';
        $this->set('backendPluginName', $this->backendPluginName);
        $this->set('backendPluginNameUnderscored', $this->backendPluginNameUnderscored);
    }

	public function beforeFilter() {
        if(!empty($this->request->query['redirect'])) {
            if(!empty($this->request->base) && strpos($this->request->query['redirect'], $this->request->base) === 0) {
                $this->request->query['redirect'] = substr($this->request->query['redirect'], strlen($this->request->base));
            }
            $this->redirectUrl = $this->request->query['redirect'];
        } else {
            if($this->request->action == 'index' && !$this->request->is('ajax')) {
                $this->redirectUrl = '/' . $this->request->url;
            } else {
                $this->redirectUrl = $this->referer(array('action' => 'index'), true);
            }
        }
        //remove this block after you created the first user
        $this->Auth->allow();
        return;
        //end remove this block after you created the first user
		$this->Auth->authorize = array('Controller');
		$this->Auth->authenticate = array('Form' => array(
                'fields' => array('username' => 'email')
            )
        );
        $this->Auth->flash = array('element' => 'default', 'key' => 'auth', 'params' => array('class' => 'alert'));
        $this->Auth->loginAction = array('controller' => $this->backendPluginNameUnderscored . '_users', 'action' => 'login', 'plugin' => $this->backendPluginNameUnderscored);
        $this->Auth->logoutRedirect = array('controller' => 'pages', 'action' => 'display', 'home', 'plugin' => false);
        $this->Auth->loginRedirect = array('controller' => $this->backendPluginNameUnderscored . '_pages', 'action' => 'display', 'home', 'plugin' => Inflector::underscore($this->backendPluginName));
	}

	public function beforeRender() {
		$this->set('redirectUrl', $this->redirectUrl);
	}

	public function isAuthorized($user = null) {
        if(!empty($user)) {
            return true;
        }
    }
}


{'fraction_non_alphanumeric': 0.18261942534814032, 'fraction_numerical': 0.00035254715318173806, 'mean_word_length': 3.1175616835994195, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 149, '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': '7311895', 'n_tokens_mistral': 1596, 'n_tokens_neox': 1572, 'n_words': 301}