Prev | Current Page 183 | Next

Rob Allen, Nick Lo, and Steven Brown

"Zend Framework in Action"

The Flash Messenger is a ???one time??? message and
automatically deletes itself when it is read. This makes it ideal for sending validation messages from one
screen to the next. In our case it is read by the login controller action and the message is assigned to the view
using this code:
$flashMessenger = $this->_helper->FlashMessenger;
$flashMessenger->setNamespace('actionErrors');
$this->view->actionErrors = $flashMessenger->getMessages();
Listing 6.6 shows the _getAuthAdapter() function which is the last part authentication puzzle. It creates an
instance of Zend_Auth_Adapter_DbTable and assigns the supplied username and password to it ready for
authentication by Zend_Auth.
Listing 6.6 The auth/identify Action
protected function _getAuthAdapter($formData)
{
$dbAdapter = Zend_Registry::get('db'); #1
$authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter);
$authAdapter->setTableName('users') |#2
->setIdentityColumn('username') |
->setCredentialColumn('password'); |
// get "salt" for better security |#3
$config = Zend_Registry::get('config'); |
$salt = $config->auth->salt; |
$password = sha1($salt.$formData['password']); |
$authAdapter->setIdentity($formData['username']); |#4
$authAdapter->setCredential($password); |
return $authAdapter;
}
(annotation) <#1.


Pages:
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
elektroenergetyka24.bieszczady.pl Wczasy nad morzem szafy buchsbaum hotele londyn