We also need to ensure that
we know the identity of the current user throughout the application, so we take advantage of the Zend
Framework??™s Front Controller plug-in system.
6.3.1 Logging in
To log in and out of our application a separate controller, called AuthController is required. We use an action
for display of the form (auth/login) and a separate action (auth/identify) to perform the actual identification.
The class skeleton therefore looks like:
class AuthController extends Zend_Controller_Action
{
public function indexAction()
Licensed to Menshu You
Please post comments or corrections to the Author Online forum at
http://www.manning-sandbox.com/forum.jspa?forumID=329
{
$this->_forward('login');
}
public function loginAction()
{
}
public function identifyAction()
{
}
}
Note that we need indexAction as it is marked abstract in the Zend_Controller_Action parent class. We
simply redirect to auth/login if someone goes to auth/index. The HTML for a log in form is very simple and
goes in the view script for the login action (scripts/auth/login.tpl.php) as show in Listing 6.4.
Listing 6.4 Log in Form: auth/login.tpl.php
Log in
Please log in here
(annotation) <#1.
Pages:
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191