1

I have depleted my resources trying to figure this out. How do I only enable the "greatly helpful" DebugKit to only load when the logged in user is an administrator? The approach I know and thought to work, is with Configure::write('debug', 1), but it has not worked. I am not sure what else I can do... This is the code I current have in the `AppController.php1 file

// AppController.php

public function beforeFilter(Event $event){
    parent::beforeFilter($event);

    // ...

    // Checks if loggedin user is an administrator
    if($this->Auth->user() && $this->Auth->user('role' == 'admin')){
        // Enable debugging and allow DebugKit to load
        Configure::write('debug', 1);
    }
}
AKKAweb
  • 3,795
  • 4
  • 33
  • 64
  • 1
    Please be aware that implementing it like this is a bad idea when pushing it into production. This renders your caching useless, as debug mode resets caches constantly. Having an admin login to your app would mean it keeps wiping the caches for all the other users too. – Oldskool Feb 27 '15 at 23:24
  • Oldskool - Thank you for your comment. I tried to do it that way because I did not know any better. I just thought there was a quick way. The application I am developing is still in the early stages and I only had dev.domain.com.I didnt want to bother at this item in implementing an environment-level configuration. I agree with you that things like that should never make it into a production environment. I will take the time and implement that now. Thanks – AKKAweb Feb 28 '15 at 00:38

0 Answers0