Prev | Current Page 185 | Next

Rob Allen, Nick Lo, and Steven Brown

"Zend Framework in Action"

The salt is private string known only to the application that we
prepend to the user??™s password to create a word that will not be in an online dictionary. This makes the hash
very, very difficult, if not impossible to reverse engineer.
At this point we have completed logging in for our application. It would however be helpful if we
provided links for logging in and out for the user. A view helper is one way to do this and encapsulates the
logic required away from the view templates themselves.
6.3.3 A view helper welcome message
To provide a welcome message within a view helper we can take advantage of the fact that Zend_Auth
implements the Singleton pattern and so we do not need to pass around an instance of it. Listing 6.7 shows the
LoggedInUser view helper.
Listing 6.6 The auth/identify Action
class Zend_View_Helper_LoggedInUser
{
protected $_view;
function setView($view) |#1
{ |
$this->_view = $view; |
} |
function loggedInUser()
{
$auth = Zend_Auth::getInstance();
if($auth->hasIdentity()) #2
{
$logoutUrl = $this->_view->linkTo('auth/logout');
$user = $auth->getIdentity(); #3
$username = $this->_view->escape(ucfirst($user->username));
$string = 'Logged in as ' . $username . ' | Log out';
} else {
$loginUrl = $this->_view->linkTo('auth/identify'); #4
$string = '173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197
wycieczki do Skandynawii traktorki ogrodowe skarpetki narciarskie męskie perfumy fm Szkoły policealne fryzjer w warszawie