We continue our effort to integrate the User
model and the authentication process into our database. This section shows the changes that are required in the controllers:
Go into the directory
/app
and create a new file. Name the fileapp_controller.php
. Add the following code to it and save:<?php class AppController extends Controller { } ?>
Now, add the Auth component to the newly created AppController class:
<?php class AppController extends Controller { var $components = array('Auth'); } ?>
Add the
beforeFilter()
function to theAppController
class, with the following code:<?php class AppController extends Controller { var $components = array('Auth'); function beforeFilter(){ $this->Auth->loginRedirect = array('controller' => 'questions', 'action' => 'home'); $this->Auth->logoutRedirect = array('controller' => 'questions', 'action' => 'home'); $this->Auth->allow('signup', 'confirm', 'home...