Skip to content

Commit

Permalink
Starting to migrate AuthComponent to the new class loader
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Mar 5, 2011
1 parent f8a0843 commit f1e2f5e
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 22 deletions.
3 changes: 2 additions & 1 deletion lib/Cake/Controller/Component/Auth/ActionsAuthorize.php
Expand Up @@ -12,7 +12,8 @@
* @link http://cakephp.org CakePHP(tm) Project
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::import('Component', 'auth/base_authorize');

App::uses('BaseAuthorize', 'Controller/Component/Auth');

/**
* An authorization adapter for AuthComponent. Provides the ability to authorize using the AclComponent,
Expand Down
3 changes: 2 additions & 1 deletion lib/Cake/Controller/Component/Auth/BaseAuthenticate.php
Expand Up @@ -12,7 +12,8 @@
* @link http://cakephp.org CakePHP(tm) Project
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::import('Core', 'Security');

App::uses('Security', 'Utility');

/**
* Base Authentication class with common methods and properties.
Expand Down
3 changes: 2 additions & 1 deletion lib/Cake/Controller/Component/Auth/BasicAuthenticate.php
Expand Up @@ -12,7 +12,8 @@
* @link http://cakephp.org CakePHP(tm) Project
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::import('Component', 'auth/base_authenticate');

App::uses('BaseAuthorize', 'Controller/Component/Auth');

/**
* Basic Authentication adapter for AuthComponent.
Expand Down
3 changes: 2 additions & 1 deletion lib/Cake/Controller/Component/Auth/ControllerAuthorize.php
Expand Up @@ -12,7 +12,8 @@
* @link http://cakephp.org CakePHP(tm) Project
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::import('Component', 'auth/base_authorize');

App::uses('BaseAuthorize', 'Controller/Component/Auth');

/**
* An authorization adapter for AuthComponent. Provides the ability to authorize using a controller callback.
Expand Down
3 changes: 2 additions & 1 deletion lib/Cake/Controller/Component/Auth/CrudAuthorize.php
Expand Up @@ -12,7 +12,8 @@
* @link http://cakephp.org CakePHP(tm) Project
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::import('Component', 'auth/base_authorize');

App::uses('BaseAuthorize', 'Controller/Component/Auth');

/**
* An authorization adapter for AuthComponent. Provides the ability to authorize using CRUD mappings.
Expand Down
3 changes: 2 additions & 1 deletion lib/Cake/Controller/Component/Auth/DigestAuthenticate.php
Expand Up @@ -12,7 +12,8 @@
* @link http://cakephp.org CakePHP(tm) Project
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::import('Component', 'auth/base_authenticate');

App::uses('BaseAuthenticate', 'Controller/Component/Auth');

/**
* Digest Authentication adapter for AuthComponent.
Expand Down
3 changes: 2 additions & 1 deletion lib/Cake/Controller/Component/Auth/FormAuthenticate.php
Expand Up @@ -12,7 +12,8 @@
* @link http://cakephp.org CakePHP(tm) Project
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::import('Component', 'auth/base_authenticate');

App::uses('BaseAuthenticate', 'Controller/Component/Auth');

/**
* An authentication adapter for AuthComponent. Provides the ability to authenticate using POST
Expand Down
8 changes: 6 additions & 2 deletions lib/Cake/Controller/Component/AuthComponent.php
Expand Up @@ -407,8 +407,10 @@ public function constructAuthorize() {
unset($config[AuthComponent::ALL]);
}
foreach ($config as $class => $settings) {
list($plugin, $class) = pluginSplit($class, true);
$className = $class . 'Authorize';
if (!class_exists($className) && !App::import('Component', 'auth/' . $class . '_authorize')) {
App::uses($className, $plugin . 'Controller/Component/Auth');
if (!class_exists($className)) {
throw new CakeException(__('Authorization adapter "%s" was not found.', $class));
}
if (!method_exists($className, 'authorize')) {
Expand Down Expand Up @@ -645,8 +647,10 @@ public function constructAuthenticate() {
unset($config[AuthComponent::ALL]);
}
foreach ($config as $class => $settings) {
list($plugin, $class) = pluginSplit($class, true);
$className = $class . 'Authenticate';
if (!class_exists($className) && !App::import('Component', 'auth/' . $class . '_authenticate')) {
App::uses($className, $plugin . 'Controller/Component/Auth');
if (!class_exists($className)) {
throw new CakeException(__('Authentication adapter "%s" was not found.', $class));
}
if (!method_exists($className, 'authenticate')) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Core/App.php
Expand Up @@ -425,7 +425,7 @@ public static function core($type = null) {
public static function objects($type, $path = null, $cache = true) {
$objects = array();
$extension = '/\.php$/';
$directories = false;
$includeDirectories = false;
$name = $type;

if (isset(self::$legacy[$type . 's'])) {
Expand Down
7 changes: 4 additions & 3 deletions lib/Cake/tests/cases/libs/controller/components/acl.test.php
Expand Up @@ -16,9 +16,10 @@
* @since CakePHP(tm) v 1.2.0.5435
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('AclComponent', 'Component');
App::uses('DbAcl', 'Model');


App::uses('AclComponent', 'Controller/Component');
App::uses('AclNode', 'Model');
class_exists('AclComponent');

/**
* AclNodeTwoTestBase class
Expand Down
11 changes: 2 additions & 9 deletions lib/Cake/tests/cases/libs/controller/components/auth.test.php
Expand Up @@ -332,15 +332,11 @@ function setUp() {

$this->Controller = new AuthTestController($request);

<<<<<<< HEAD
ClassRegistry::addObject('view', new View($this->Controller));
=======
$collection = new ComponentCollection();
$collection->init($this->Controller);
$this->Auth = new TestAuthComponent($collection);
$this->Auth->request = $request;
$this->Auth->response = $this->getMock('CakeResponse');
>>>>>>> origin/2.0

$this->Controller->Components->init($this->Controller);

Expand Down Expand Up @@ -935,7 +931,6 @@ function testAdminRoute() {
}

/**
<<<<<<< HEAD
* testPluginModel method
*
* @access public
Expand All @@ -946,7 +941,7 @@ function testPluginModel() {
Cache::delete('object_map', '_cake_core_');
App::build(array(
'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
'models' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'models' . DS)
'Model' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'models' . DS)
), true);
App::objects('plugin', null, false);

Expand Down Expand Up @@ -996,16 +991,14 @@ function testPluginModel() {
}

/**
=======
>>>>>>> origin/2.0
* testAjaxLogin method
*
* @access public
* @return void
*/
function testAjaxLogin() {
App::build(array(
'views' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views'. DS)
'View' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views'. DS)
));
$_SERVER['HTTP_X_REQUESTED_WITH'] = "XMLHttpRequest";

Expand Down

0 comments on commit f1e2f5e

Please sign in to comment.