mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 17:16:18 +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
|
||||
*/
|
||||
public function startup($controller) {
|
||||
$isErrorOrTests = (
|
||||
strtolower($controller->name) == 'cakeerror' ||
|
||||
(strtolower($controller->name) == 'tests' && Configure::read('debug') > 0)
|
||||
);
|
||||
if ($isErrorOrTests) {
|
||||
if ($controller->name == 'CakeError') {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -342,12 +338,7 @@ class AuthComponent extends Component {
|
|||
if (!$this->user()) {
|
||||
if (!$request->is('ajax')) {
|
||||
$this->flash($this->authError);
|
||||
if (!empty($request->query) && count($request->query) >= 2) {
|
||||
$query = $request->query;
|
||||
unset($query['url'], $query['ext']);
|
||||
$url .= Router::queryString($query, array());
|
||||
}
|
||||
$this->Session->write('Auth.redirect', $url);
|
||||
$this->Session->write('Auth.redirect', Router::reverse($request));
|
||||
$controller->redirect($loginAction);
|
||||
return false;
|
||||
} elseif (!empty($this->ajaxLogin)) {
|
||||
|
@ -361,11 +352,7 @@ class AuthComponent extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
if (!$this->authorize) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($this->isAuthorized()) {
|
||||
if (empty($this->authorize) || $this->isAuthorized()) {
|
||||
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
|
||||
* 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.
|
||||
*
|
||||
* @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->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
|
||||
$_SERVER['HTTP_REFERER'] = false;
|
||||
$_ENV['HTTP_REFERER'] = false;
|
||||
|
@ -969,7 +958,6 @@ class AuthTest extends CakeTestCase {
|
|||
|
||||
$this->Controller->Auth->initialize($this->Controller);
|
||||
$this->Controller->Auth->authorize = 'controller';
|
||||
$this->Controller->request['testControllerAuth'] = true;
|
||||
|
||||
$this->Controller->Auth->loginAction = array(
|
||||
'controller' => 'AuthTest', 'action' => 'login'
|
||||
|
@ -1041,8 +1029,7 @@ class AuthTest extends CakeTestCase {
|
|||
$_GET = array(
|
||||
'url' => '/posts/index/29',
|
||||
'print' => 'true',
|
||||
'refer' => 'menu',
|
||||
'ext' => 'html'
|
||||
'refer' => 'menu'
|
||||
);
|
||||
$this->Controller->Session->delete('Auth');
|
||||
$url = '/posts/index/29';
|
||||
|
|
Loading…
Add table
Reference in a new issue