mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Fixed admin routing redirect in AuthComponent
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6886 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
6614bc96ab
commit
bf107d1886
2 changed files with 28 additions and 2 deletions
|
@ -279,7 +279,7 @@ class AuthComponent extends Object {
|
|||
}
|
||||
|
||||
if (is_array($this->loginAction)) {
|
||||
$this->loginAction = $this->loginAction['controller'].'/'.$this->loginAction['action'];
|
||||
$this->loginAction = Router::url($this->loginAction);
|
||||
$url = $controller->params['controller'].'/'.$controller->params['action'];
|
||||
}
|
||||
$this->loginAction = Router::normalize($this->loginAction);
|
||||
|
|
|
@ -66,6 +66,8 @@ class AuthTestController extends Controller {
|
|||
var $uses = array('AuthUser');
|
||||
var $components = array('Auth', 'Acl');
|
||||
|
||||
var $testUrl = null;
|
||||
|
||||
function __construct() {
|
||||
$this->params = Router::parse('/auth_test');
|
||||
Router::setRequestInfo(array($this->params, array('base' => null, 'here' => '/auth_test', 'webroot' => '/', 'passedArgs' => array(), 'argSeparator' => ':', 'namedArgs' => array())));
|
||||
|
@ -78,6 +80,9 @@ class AuthTestController extends Controller {
|
|||
function login() {
|
||||
}
|
||||
|
||||
function admin_login() {
|
||||
}
|
||||
|
||||
function logout() {
|
||||
//$this->redirect($this->Auth->logout());
|
||||
}
|
||||
|
@ -85,7 +90,8 @@ class AuthTestController extends Controller {
|
|||
function add() {
|
||||
}
|
||||
|
||||
function redirect() {
|
||||
function redirect($url, $status, $exit) {
|
||||
$this->testUrl = Router::url($url);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -440,6 +446,26 @@ class AuthTest extends CakeTestCase {
|
|||
$this->assertTrue(!!$user);
|
||||
}
|
||||
|
||||
function testAdminRoute() {
|
||||
Router::reload();
|
||||
$admin = Configure::read('Routing.admin');
|
||||
Configure::write('Routing.admin', 'admin');
|
||||
|
||||
$url = '/admin/something';
|
||||
$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->initialize($this->Controller);
|
||||
|
||||
$this->Controller->Auth->loginAction = array('admin' => true, 'controller' => 'auth_test', 'action' => 'login');
|
||||
$this->Controller->Auth->userModel = 'AuthUser';
|
||||
|
||||
$this->Controller->Auth->startup($this->Controller);
|
||||
$this->assertEqual($this->Controller->testUrl, '/admin/auth_test/login');
|
||||
|
||||
Configure::write('Routing.admin', $admin);
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
unset($this->Controller, $this->AuthUser);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue