/** * Note this is just an action handler -- * it either forks back to loginAction or to the root index. * */ public function loginvalidateAction() { $login_form = new Zupal_People_Loginform(); if ($login_form->isValid($this->_getAllParams())) { $values = $login_form->getValues(); $authorizer = new Zupal_People_Authorizer($values['username'], $values['password']); $auth = Zend_Auth::getInstance(); $result = $auth->authenticate($authorizer); if (!$result->isValid()) { $this->_forward('login', NULL, NULL, array('message' => 'Sorry, bad login')); } } else { $this->_forward('login', NULL, NULL, array('message' => 'Sorry, bad login')); } }
public function LoginPanel() { $cache = Zupal_Bootstrap::$registry->cache; $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { // Identity exists; get it $identity = $auth->getIdentity(); if (!$cache->test('people_login_panel_logged_in')) { ob_start(); ?> <div class="panel"> Logged in as <b>%s</b><br /> <?php echo new Zupal_Control_Link('Log Out', array('controller' => 'users', 'module' => 'people', 'action' => 'logout')); ?> </div> <?php $cache->save(ob_get_clean(), 'people_login_panel_logged_in'); } return sprintf($cache->load('people_login_panel_logged_in'), $identity['username']); } else { if (!$cache->test('people_form')) { ob_start(); ?> <div class="panel"> <h3>Log In</h3> <?php $form = new Zupal_People_Loginform(); ?> <?php echo $form->render(); ?> </div> <?php $cache->save(ob_get_clean(), 'people_form'); } return $cache->load('people_form'); } }