mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 02:26:17 +00:00
adding Object::stop(), updating auth and auth.test to use
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6901 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
3d251e4145
commit
8a236492a0
3 changed files with 38 additions and 30 deletions
|
@ -242,7 +242,7 @@ class AuthComponent extends Object {
|
|||
));
|
||||
}
|
||||
if (Configure::read() > 0) {
|
||||
uses('debugger');
|
||||
App::import('Debugger');
|
||||
Debugger::checkSessionKey();
|
||||
}
|
||||
}
|
||||
|
@ -318,6 +318,7 @@ class AuthComponent extends Object {
|
|||
} elseif (!empty($this->ajaxLogin)) {
|
||||
$controller->viewPath = 'elements';
|
||||
echo $controller->render($this->ajaxLogin, 'ajax');
|
||||
$this->stop();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -127,6 +127,16 @@ class Object {
|
|||
break;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Stop execution of the current script
|
||||
*
|
||||
* @param $status see http://php.net/exit for values
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function stop($status = 0) {
|
||||
exit($status);
|
||||
}
|
||||
/**
|
||||
* API for logging events.
|
||||
*
|
||||
|
|
|
@ -30,6 +30,21 @@ App::import(array('controller' . DS . 'components' . DS .'auth', 'controller' .
|
|||
|
||||
App::import(array('controller'.DS.'components'.DS.'acl', 'model'.DS.'db_acl'));
|
||||
Configure::write('Security.salt', 'JfIxfs2guVoUubWDYhG93b0qyJfIxfs2guwvniR2G0FgaC9mi');
|
||||
/**
|
||||
* Short description for class.
|
||||
*
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.cases.libs.controller.components
|
||||
*/
|
||||
class TestAuthComponent extends AuthComponent {
|
||||
|
||||
var $testStop = false;
|
||||
|
||||
function stop() {
|
||||
$this->testStop = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Short description for class.
|
||||
*
|
||||
|
@ -106,17 +121,19 @@ class AuthTestController extends Controller {
|
|||
|
||||
class AjaxAuthController extends Controller {
|
||||
var $name = 'AjaxAuth';
|
||||
var $components = array('Auth');
|
||||
var $components = array('TestAuth');
|
||||
var $uses = array();
|
||||
var $testUrl = null;
|
||||
|
||||
function beforeFilter() {
|
||||
$this->Auth->ajaxLogin = 'test_element';
|
||||
$this->Auth->userModel = 'AuthUser';
|
||||
$this->TestAuth->ajaxLogin = 'test_element';
|
||||
$this->TestAuth->userModel = 'AuthUser';
|
||||
}
|
||||
function add() {
|
||||
if ($this->TestAuth->testStop !== true) {
|
||||
echo 'Added Record';
|
||||
}
|
||||
}
|
||||
function redirect($url, $status, $exit) {
|
||||
$this->testUrl = Router::url($url);
|
||||
return false;
|
||||
|
@ -490,25 +507,6 @@ class AuthTest extends CakeTestCase {
|
|||
Configure::write('viewPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS));
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = "XMLHttpRequest";
|
||||
|
||||
$url = '/auth_test/add';
|
||||
$this->Controller->params = Router::parse($url);
|
||||
Router::setRequestInfo(array($this->Controller->passedArgs, array('base' => null, 'here' => $url, 'webroot' => '/', 'passedArgs' => array(), 'argSeparator' => ':', 'namedArgs' => array())));
|
||||
|
||||
$this->Controller->Auth->RequestHandler->startup($this->Controller);
|
||||
$this->Controller->Auth->initialize($this->Controller);
|
||||
|
||||
$this->Controller->Auth->loginAction = array('controller' => 'auth_test', 'action' => 'login');
|
||||
$this->Controller->Auth->userModel = 'AuthUser';
|
||||
|
||||
$this->Controller->Auth->ajaxLogin = 'test_element';
|
||||
|
||||
ob_start();
|
||||
$this->Controller->Auth->startup($this->Controller);
|
||||
$result = ob_get_clean();
|
||||
|
||||
$this->assertPattern('/test element/', $result);
|
||||
$this->assertNoPattern('/add/', $result);
|
||||
|
||||
if (!class_exists('dispatcher')) {
|
||||
require CAKE . 'dispatcher.php';
|
||||
}
|
||||
|
@ -520,7 +518,6 @@ class AuthTest extends CakeTestCase {
|
|||
$result = ob_get_clean();
|
||||
$this->assertPattern('/test element/', $result);
|
||||
$this->assertNoPattern('/Added Record/', $result);
|
||||
|
||||
unset($_SERVER['HTTP_X_REQUESTED_WITH']);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue