mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-03-18 07:29:51 +00:00
Removing custom request reversal code, and using Router::reverse()
Removing dead tests that are covered by Router tests. Removing check for TestsController, it hasn't existed in forever.
This commit is contained in:
parent
f2bba3d36e
commit
ed122c70f4
2 changed files with 5 additions and 31 deletions
|
@ -288,11 +288,7 @@ class AuthComponent extends Component {
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function startup($controller) {
|
public function startup($controller) {
|
||||||
$isErrorOrTests = (
|
if ($controller->name == 'CakeError') {
|
||||||
strtolower($controller->name) == 'cakeerror' ||
|
|
||||||
(strtolower($controller->name) == 'tests' && Configure::read('debug') > 0)
|
|
||||||
);
|
|
||||||
if ($isErrorOrTests) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -342,12 +338,7 @@ class AuthComponent extends Component {
|
||||||
if (!$this->user()) {
|
if (!$this->user()) {
|
||||||
if (!$request->is('ajax')) {
|
if (!$request->is('ajax')) {
|
||||||
$this->flash($this->authError);
|
$this->flash($this->authError);
|
||||||
if (!empty($request->query) && count($request->query) >= 2) {
|
$this->Session->write('Auth.redirect', Router::reverse($request));
|
||||||
$query = $request->query;
|
|
||||||
unset($query['url'], $query['ext']);
|
|
||||||
$url .= Router::queryString($query, array());
|
|
||||||
}
|
|
||||||
$this->Session->write('Auth.redirect', $url);
|
|
||||||
$controller->redirect($loginAction);
|
$controller->redirect($loginAction);
|
||||||
return false;
|
return false;
|
||||||
} elseif (!empty($this->ajaxLogin)) {
|
} elseif (!empty($this->ajaxLogin)) {
|
||||||
|
@ -361,11 +352,7 @@ class AuthComponent extends Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->authorize) {
|
if (empty($this->authorize) || $this->isAuthorized()) {
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->isAuthorized()) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -519,7 +506,7 @@ class AuthComponent extends Component {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log a user in. If a $user is provided that data will be stored as the logged in user. If `$user` is empty or not
|
* Log a user in. If a $user is provided that data will be stored as the logged in user. If `$user` is empty or not
|
||||||
* specified, POST data from the current request will be used to identify a user. If the login was successful,
|
* specified, the request will be used to identify a user. If the identification was successful,
|
||||||
* the user record is written to the session key specified in AuthComponent::$sessionKey.
|
* the user record is written to the session key specified in AuthComponent::$sessionKey.
|
||||||
*
|
*
|
||||||
* @param mixed $user Either an array of user data, or null to identify a user using the current request.
|
* @param mixed $user Either an array of user data, or null to identify a user using the current request.
|
||||||
|
|
|
@ -943,17 +943,6 @@ class AuthTest extends CakeTestCase {
|
||||||
|
|
||||||
$this->Controller->Session->delete('Auth');
|
$this->Controller->Session->delete('Auth');
|
||||||
|
|
||||||
$this->Controller->request->query['url'] = 'admin/';
|
|
||||||
$this->Controller->Auth->initialize($this->Controller);
|
|
||||||
$this->Controller->Auth->userModel = 'AuthUser';
|
|
||||||
$this->Controller->Auth->loginRedirect = null;
|
|
||||||
$this->Controller->Auth->startup($this->Controller);
|
|
||||||
$expected = Router::normalize('admin/');
|
|
||||||
$this->assertTrue($this->Controller->Session->check('Message.auth'));
|
|
||||||
$this->assertEqual($expected, $this->Controller->Auth->redirect());
|
|
||||||
|
|
||||||
$this->Controller->Session->delete('Auth');
|
|
||||||
|
|
||||||
//empty referer no session
|
//empty referer no session
|
||||||
$_SERVER['HTTP_REFERER'] = false;
|
$_SERVER['HTTP_REFERER'] = false;
|
||||||
$_ENV['HTTP_REFERER'] = false;
|
$_ENV['HTTP_REFERER'] = false;
|
||||||
|
@ -969,7 +958,6 @@ class AuthTest extends CakeTestCase {
|
||||||
|
|
||||||
$this->Controller->Auth->initialize($this->Controller);
|
$this->Controller->Auth->initialize($this->Controller);
|
||||||
$this->Controller->Auth->authorize = 'controller';
|
$this->Controller->Auth->authorize = 'controller';
|
||||||
$this->Controller->request['testControllerAuth'] = true;
|
|
||||||
|
|
||||||
$this->Controller->Auth->loginAction = array(
|
$this->Controller->Auth->loginAction = array(
|
||||||
'controller' => 'AuthTest', 'action' => 'login'
|
'controller' => 'AuthTest', 'action' => 'login'
|
||||||
|
@ -1041,8 +1029,7 @@ class AuthTest extends CakeTestCase {
|
||||||
$_GET = array(
|
$_GET = array(
|
||||||
'url' => '/posts/index/29',
|
'url' => '/posts/index/29',
|
||||||
'print' => 'true',
|
'print' => 'true',
|
||||||
'refer' => 'menu',
|
'refer' => 'menu'
|
||||||
'ext' => 'html'
|
|
||||||
);
|
);
|
||||||
$this->Controller->Session->delete('Auth');
|
$this->Controller->Session->delete('Auth');
|
||||||
$url = '/posts/index/29';
|
$url = '/posts/index/29';
|
||||||
|
|
Loading…
Add table
Reference in a new issue