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
|
||||
*/
|
||||
function startup(&$controller) {
|
||||
$methods = array_flip($controller->methods);
|
||||
$isErrorOrTests = (
|
||||
strtolower($controller->name) == 'cakeerror' ||
|
||||
(strtolower($controller->name) == 'tests' && Configure::read() > 0) ||
|
||||
!in_array(strtolower($controller->params['action']), $controller->methods)
|
||||
(strtolower($controller->name) == 'tests' && Configure::read() > 0)
|
||||
);
|
||||
if ($isErrorOrTests) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$isMissingAction = (
|
||||
$controller->scaffold === false &&
|
||||
!isset($methods[strtolower($controller->params['action'])])
|
||||
);
|
||||
|
||||
if ($isMissingAction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!$this->__setDefaults()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -282,6 +292,7 @@ class AuthComponent extends Object {
|
|||
}
|
||||
$url = Router::normalize($url);
|
||||
$loginAction = Router::normalize($this->loginAction);
|
||||
|
||||
$isAllowed = (
|
||||
$this->allowedActions == array('*') ||
|
||||
in_array($controller->params['action'], $this->allowedActions)
|
||||
|
|
|
@ -448,6 +448,26 @@ class AuthTest extends CakeTestCase {
|
|||
function testNoAuth() {
|
||||
$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
|
||||
*
|
||||
|
@ -812,7 +832,7 @@ class AuthTest extends CakeTestCase {
|
|||
/**
|
||||
* Ensure that no redirect is performed when a 404 is reached
|
||||
* And the user doesn't have a session.
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
function testNoRedirectOn404() {
|
||||
|
@ -894,7 +914,7 @@ class AuthTest extends CakeTestCase {
|
|||
|
||||
$this->Controller->Auth->startup($this->Controller);
|
||||
$this->assertTrue(is_null($this->Controller->Auth->user()));
|
||||
|
||||
|
||||
unset($this->Controller->data['AuthUser']['password']);
|
||||
$this->Controller->data['AuthUser']['username'] = "1'1";
|
||||
$this->Controller->Auth->initialize($this->Controller);
|
||||
|
@ -980,7 +1000,7 @@ class AuthTest extends CakeTestCase {
|
|||
$this->Controller->Auth->startup($this->Controller);
|
||||
$user = $this->Controller->Auth->user();
|
||||
$this->assertTrue(!!$user);
|
||||
|
||||
|
||||
$this->Controller->Session->del('Auth');
|
||||
Router::reload();
|
||||
Router::connect('/', array('controller' => 'people', 'action' => 'login'));
|
||||
|
@ -1152,4 +1172,4 @@ class AuthTest extends CakeTestCase {
|
|||
unset($this->Controller, $this->AuthUser);
|
||||
}
|
||||
}
|
||||
?>
|
||||
?>
|
Loading…
Add table
Reference in a new issue