Subscribe to RSS Subscribe to Comments

Alan Blaine Whitney

Cake 1.2 Final Auth Problems

I had auth working in 1.2RC3 just fine. What I wanted was all of the non-admin stuff to not need auth, but all of the admin stuff to have auth. Here is what my code used to look like

	function beforeFilter() {
		$this->Auth->allow('*');
		if (isset($this->params['admin'])) {
 			$this->Auth->deny("*");
		}
       }

That didn’t work in 1.2 final, here was the modification I had to make to get it working again.

	function beforeFilter() {
		$this->Auth->allow('*'); // Allow Everything by default
		$admin = (Configure::read('Routing.admin'));
		$strlen = strlen($admin);
		foreach ($this->Auth->allowedActions as $key) { 
			if (substr($key, 0, $strlen) == $admin) { 
				$this->Auth->deny($key); // Disable an admin_ like action
			}
		}
 
		if (is_a($this, "UsersController")) { 
			$this->Auth->deny('login');
		}
 
		if (isset($this->params['admin'])) { 
			$this->layout='admin';
		}
 
		if ($this->RequestHandler->isAjax()) { 
			$this->layout='ajax';
		}
    }

That seemed to fix it up. Go figure.

No comments yet. Be the first.

Leave a reply

Based on FluidityTheme Redesigned by Kaushal Sheth Sponsored by Send Flowers