<commit_before><?php
/**
 * @package UI-infra
 * @subpackage Authentication
 */
class Infra_AuthPlugin extends Zend_Controller_Plugin_Abstract 
{
	private static $_whitelist = array(
			'error/error', 
			'error/denied', 
			'user/login', 
			'user/reset-password', 
			'user/reset-password-link', 
			'user/reset-password-ok',
			
		);
	
	public function __construct() 
	{
		
	}
	
	/**
	 * Add a certain URL to the whitelist
	 * @param string $url
	 */
	public static function addToWhitelist ($url)
	{
	    self::$_whitelist[] = $url;
	}
	
	public function preDispatch(Zend_Controller_Request_Abstract $request) 
	{
		$controller = strtolower($request->getControllerName());
		$action = strtolower($request->getActionName());
		$route = $controller . '/' . $action;
		
		if (in_array($route, self::$_whitelist)) {
			return;
		}
		
		$auth = Infra_AuthHelper::getAuthInstance();
		if ($auth->hasIdentity()) {
			return;
		}
		
		$request->setDispatched(false);
		$request->setControllerName('user');
		$request->setActionName('login');
		$request->setParam('next_uri', $request->getPathInfo());<commit_msg>qnd: enable configurable default login page<commit_after><?php
/**
 * @package UI-infra
 * @subpackage Authentication
 */
class Infra_AuthPlugin extends Zend_Controller_Plugin_Abstract 
{
	/**
	 * The default controller name
	 * @var string
	 */
	private static $defaultController = 'user';
	
	/**
	 * The default action name
	 * @var string
	 */
	private static $defaultAction = 'login';
	
	private static $_whitelist = array(
			'error/index', 
			'error/error', 
			'error/denied', 
			'user/login', 
			'user/reset-password', 
			'user/reset-password-link', 
			'user/reset-password-ok',
			
		);
	
	public function __construct() 
	{
		
	}
	
	/**
	 * Define the default action when login failed
	 * @param string $url
	 */
	public static function setDefaultAction($controller, $action = 'index')
	{
	    self::$defaultController = $controller;
	    self::$defaultAction = $action;
	}
	
	/**
	 * Add a certain URL to the whitelist
	 * @param string $url
	 */
	public static function addToWhitelist ($url)
	{
	    self::$_whitelist[] = strtolower($url);
	}
	
	public function preDispatch(Zend_Controller_Request_Abstract $request) 
	{
		$controller = strtolower($request->getControllerName());
		$action = strtolower($request->getActionName());
		$route = $controller . '/' . $action;
		
		if (in_array($route, self::$_whitelist)) {
			return;
		}
		
		$auth = Infra_AuthHelper::getAuthInstance();
		if ($auth->hasIdentity()) {
			return;
		}
		
		$request->setDispatched(false);
		$request->setControllerName(self::$defaultController);
		$request->setActionName(self::$defaultAction);
		$request->setParam('next_uri', $request->getPathInfo());
{'fraction_non_alphanumeric': 0.15110788231020705, 'fraction_numerical': 0.0, 'mean_word_length': 3.891651865008881, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, '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': '2109744', 'n_tokens_mistral': 1001, 'n_tokens_neox': 869, 'n_words': 173}