class AppController extends Controller {

        function beforeFilter () {
                if (!$this->Session->check('User') && $this->params['action'] !=
'login') {

                        if (!$this->RequestHandler->isAjax()) {
                                // If this is not an Ajax Request, just 
redirect the user to the
login
                                
$this->redirect('/accounts/login/'.$this->params['url']['url']);
                                exit();
                        } else {
                                // Otherwise, throw up a login error with a 
link back to the login
                                $this->set('url', $this->referer());
                                $this->viewPath = 'elements';
                                $this->render('login_error', 'ajax');
                                exit();
                        }
                }
        }
}

class AccountsController extends AppController {

        function login () {

                if (!empty($this->data)) {
                        if ($login = $this->Contact->login($this->data)) {
                                $params = func_get_args();
                                $url = empty($params) || in_array('logout', 
$params) ? '/' : '/' .
implode('/', $params);

                                $this->Session->write('Contact', 
$login['Contact']);
                                $this->redirect($url);
                                exit();
                        }
                }
        }
}


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"Cake PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to