Q:

Cakephp, allow user to choose public access to auth controlled page

I'm using CakePHP's Auth component and I'm wondering whats the best way to allow the user to decide whether or not they give public access to their own page, ie.  /user/username/public.  So i'd have a checkbox in their profile page and save a 1 or a 0 in the DB for a "Public" field.  However, whats the best way to allow the Auth component to conditionally allow access to this page? 

A:

That's not really a job for the Auth component, but for custom code. 
public function userProfile($username) {
    $profile = $this->Profile->find('first', array('conditions' => array(
        'username' => $username,
        'public'   => true
    )));
    if (! $profile) {
        $this->cakeError('error404');
    }
    ...
}

You could use an isAuthenticated callback, but passing around the condition would become somewhat messy.  The Auth component is handling general authentication, this case is too specialized to cleanly handle it using Auth.