title: CakePHP Auth Deny Admin Routing Pages
body: <p>I have been reading Stack Overflow questions all afternoon trying to figure this out..</p>
  
  <p>I have a users controller with index/login/logout/register functions but also has admin_index/admin_add/admin_edit/admin_delete etc.</p>
  
  <p>I have Auth component enabled and in my users_controller i am trying to deny access to the admin_* pages if the <code>Auth.User.role != 'admin'</code>, when i enable the <code>$this-&gt;Auth-&gt;authorize = 'controller';</code> it denies access to the site.com/admin/users/ page and also seems to kill the logout function even tho my account has the role set to admin.</p>
  
  <p>However if i type the url in i get redirected back to the main homepage.</p>
  
  <p>users_controller.php</p>
  
  <pre><code>&lt;?php
  class UsersController extends AppController {
  
      var $name = 'Users';
  
      function beforeFilter(){
          parent::beforeFilter();
          $this-&gt;Auth-&gt;authorize = 'controller';
          $this-&gt;Auth-&gt;allow('register');
      }
  
      function isAuthorized() {
          if ($this-&gt;Auth-&gt;user('role') != 'admin') {
              $this-&gt;Auth-&gt;deny('admin_index','admin_view', 'admin_add', 'admin_edit','admin_delete');
          }
      }
  </code></pre>
  
  <p>app_controller.php</p>
  
  <pre><code>&lt;?php
  class AppController extends Controller {
  
      var $components = array('Auth', 'Session');
  
      function beforeFilter() {
          $this-&gt;Auth-&gt;loginAction = array('controller'=&gt;'users','action'=&gt;'login', 'admin'=&gt;false);
          $this-&gt;Auth-&gt;logoutRedirect = array('controller'=&gt;'users','action'=&gt;'logout');
          $this-&gt;Auth-&gt;loginRedirect = array('controller'=&gt;'shows', 'action'=&gt;'index');
          $this-&gt;Auth-&gt;autoRedirect = false;
          $this-&gt;Auth-&gt;allow('home');
      }
  </code></pre>
  
  <p>My Second question relates to the way <code>$this-&gt;Auth-&gt;deny('page');</code> redirects the user, as far as i can tell it redirects to / but i need it to redirect back to the users controller.</p>
  
  <p>Hope it all makes sense and i have provided enough info..</p>