mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
fixes #6062, AuthComponent and Controller::scaffold
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8018 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
bf1e080aeb
commit
f7dd0800d1
2 changed files with 37 additions and 6 deletions
|
@ -262,14 +262,24 @@ class AuthComponent extends Object {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function startup(&$controller) {
|
function startup(&$controller) {
|
||||||
|
$methods = array_flip($controller->methods);
|
||||||
$isErrorOrTests = (
|
$isErrorOrTests = (
|
||||||
strtolower($controller->name) == 'cakeerror' ||
|
strtolower($controller->name) == 'cakeerror' ||
|
||||||
(strtolower($controller->name) == 'tests' && Configure::read() > 0) ||
|
(strtolower($controller->name) == 'tests' && Configure::read() > 0)
|
||||||
!in_array(strtolower($controller->params['action']), $controller->methods)
|
|
||||||
);
|
);
|
||||||
if ($isErrorOrTests) {
|
if ($isErrorOrTests) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$isMissingAction = (
|
||||||
|
$controller->scaffold === false &&
|
||||||
|
!isset($methods[strtolower($controller->params['action'])])
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($isMissingAction) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$this->__setDefaults()) {
|
if (!$this->__setDefaults()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -282,6 +292,7 @@ class AuthComponent extends Object {
|
||||||
}
|
}
|
||||||
$url = Router::normalize($url);
|
$url = Router::normalize($url);
|
||||||
$loginAction = Router::normalize($this->loginAction);
|
$loginAction = Router::normalize($this->loginAction);
|
||||||
|
|
||||||
$isAllowed = (
|
$isAllowed = (
|
||||||
$this->allowedActions == array('*') ||
|
$this->allowedActions == array('*') ||
|
||||||
in_array($controller->params['action'], $this->allowedActions)
|
in_array($controller->params['action'], $this->allowedActions)
|
||||||
|
|
|
@ -448,6 +448,26 @@ class AuthTest extends CakeTestCase {
|
||||||
function testNoAuth() {
|
function testNoAuth() {
|
||||||
$this->assertFalse($this->Controller->Auth->isAuthorized());
|
$this->assertFalse($this->Controller->Auth->isAuthorized());
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* testIsErrorOrTests
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function testIsErrorOrTests() {
|
||||||
|
$this->Controller->Auth->initialize($this->Controller);
|
||||||
|
|
||||||
|
$this->Controller->name = 'CakeError';
|
||||||
|
$this->assertTrue($this->Controller->Auth->startup($this->Controller));
|
||||||
|
|
||||||
|
$this->Controller->name = 'Post';
|
||||||
|
$this->Controller->params['action'] = 'thisdoesnotexist';
|
||||||
|
$this->assertTrue($this->Controller->Auth->startup($this->Controller));
|
||||||
|
|
||||||
|
$this->Controller->scaffold = null;
|
||||||
|
$this->Controller->params['action'] = 'index';
|
||||||
|
$this->assertFalse($this->Controller->Auth->startup($this->Controller));
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* testLogin method
|
* testLogin method
|
||||||
*
|
*
|
||||||
|
@ -812,7 +832,7 @@ class AuthTest extends CakeTestCase {
|
||||||
/**
|
/**
|
||||||
* Ensure that no redirect is performed when a 404 is reached
|
* Ensure that no redirect is performed when a 404 is reached
|
||||||
* And the user doesn't have a session.
|
* And the user doesn't have a session.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
**/
|
**/
|
||||||
function testNoRedirectOn404() {
|
function testNoRedirectOn404() {
|
||||||
|
@ -894,7 +914,7 @@ class AuthTest extends CakeTestCase {
|
||||||
|
|
||||||
$this->Controller->Auth->startup($this->Controller);
|
$this->Controller->Auth->startup($this->Controller);
|
||||||
$this->assertTrue(is_null($this->Controller->Auth->user()));
|
$this->assertTrue(is_null($this->Controller->Auth->user()));
|
||||||
|
|
||||||
unset($this->Controller->data['AuthUser']['password']);
|
unset($this->Controller->data['AuthUser']['password']);
|
||||||
$this->Controller->data['AuthUser']['username'] = "1'1";
|
$this->Controller->data['AuthUser']['username'] = "1'1";
|
||||||
$this->Controller->Auth->initialize($this->Controller);
|
$this->Controller->Auth->initialize($this->Controller);
|
||||||
|
@ -980,7 +1000,7 @@ class AuthTest extends CakeTestCase {
|
||||||
$this->Controller->Auth->startup($this->Controller);
|
$this->Controller->Auth->startup($this->Controller);
|
||||||
$user = $this->Controller->Auth->user();
|
$user = $this->Controller->Auth->user();
|
||||||
$this->assertTrue(!!$user);
|
$this->assertTrue(!!$user);
|
||||||
|
|
||||||
$this->Controller->Session->del('Auth');
|
$this->Controller->Session->del('Auth');
|
||||||
Router::reload();
|
Router::reload();
|
||||||
Router::connect('/', array('controller' => 'people', 'action' => 'login'));
|
Router::connect('/', array('controller' => 'people', 'action' => 'login'));
|
||||||
|
@ -1152,4 +1172,4 @@ class AuthTest extends CakeTestCase {
|
||||||
unset($this->Controller, $this->AuthUser);
|
unset($this->Controller, $this->AuthUser);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
Loading…
Add table
Reference in a new issue