protected function isAdmin() { $_user = Zend_auth::getInstance()->getIdentity(); if ($_user && strstr($_user->role_name, 'admin')) { return true; } }
/** * check if email or password exists in database * @param array post data */ protected function _checkAccount($post) { $login = new User_Model_Login(); $loginStatus = array(); $emailStatus = false; $passwordStatus = false; $adapter = $this->_getAuthAdapter(); $adapter->setIdentity($post['user-email'])->setCredential($post['password']); require_once APPLICATION_PATH . '/../library/Zend/Auth.php'; $auth = Zend_auth::getInstance(); $result = $auth->authenticate($adapter); if ($result->isValid()) { //login successful Zend_Session::start(); $user = $adapter->getResultRowObject(); $auth->getStorage()->write($user); $user_session = new Zend_Session_Namespace('Zend_Auth'); $user_session->email = Zend_Auth::getInstance()->getStorage()->read()->email; Zend_Session::rememberMe(); $this->redirect('index/index'); } else { if ($result->getCode() == Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND) { $this->view->loginStatus = '帳號不存在'; } else { if ($result->getCode() == Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID) { $this->view->loginStatus = '密碼錯誤'; } else { $this->view->loginStatus = '請重新登入'; } } } }
public function logoutAction() { $service = new Application_Model_Service(); if (Zend_auth::getInstance()->hasIdentity()) { $service->logout(); } $this->_redirect("/"); }
public function loggedInAs() { $auth = Zend_auth::getInstance(); if ($auth->hasIdentity()) { $email_id = $auth->getIdentity()->email; return "Welcome" . " " . "<b>" . $email_id . "</b>"; } }
public function loggedInAs() { $auth = Zend_auth::getInstance(); if ($auth->hasIdentity()) { $email_id = $auth->getIdentity()->email_id; return $email_id; } }
public function init() { if (false == Zetta_Acl::getInstance()->isAllowed('admin')) { throw new Exception('Access Denied'); } $this->_helper->getHelper('AjaxContext')->addActionContext('managepanel', 'html')->addActionContext('favoriteslist', 'html')->initContext(); $this->_user = Zend_auth::getInstance()->getIdentity(); $this->_model = new Modules_Admin_Model_Panel(); }
protected function _initAutoload() { $modelLoader = new Zend_Application_Module_Autoloader(array('namespace' => '', 'basePath' => APPLICATION_PATH . '/modules/default')); if (Zend_auth::getInstance()->hasIdentity()) { Zend_Registry::set('role', Zend_Auth::getInstance()->getStorage()->read()->role); } else { Zend_Registry::set('role', 'guest'); } $this->_acl = new Model_LibraryAcl(); //$this->_auth = Zend_Auth::getInstance(); $fc = Zend_Controller_Front::getInstance(); $fc->registerPlugin(new Plugin_AccessCheck($this->_acl)); //, $this->_auth)); return $modelLoader; }
public function menu($menu_id) { $_modelMenu = new Modules_Menu_Model_Menu(); $this->view->addBasePath(HEAP_PATH . DS . 'Menu/App/views')->addBasePath(MODULES_PATH . DS . 'Menu/App/views'); $this->view->menu_id = $menu_id; $this->view->tree = $_modelMenu->getMenuTree($menu_id); try { $return = $this->view->render('menu_' . $menu_id . '/index.phtml'); } catch (Exception $e) { $return = $this->view->render('menu/index.phtml'); } $_user = Zend_auth::getInstance()->getIdentity(); if ($_user && strstr($_user->role_name, 'admin')) { $this->view->content = $return; $return = $this->view->render('menu/adminWrapper.phtml'); } return $return; }
public function login($email, $passwd) { $autoloader = Zend_Loader_Autoloader::getInstance(); $autoloader->setFallbackAutoloader(true); $params = array('host' => '127.0.0.1', 'username' => 'root', 'password' => 'cc73b4c634', 'dbname' => 'mkdb'); $db = Zend_Db::factory('Pdo_Mysql', $params); $auth = Zend_auth::getInstance(); $auth->setStorage(new Zend_Auth_Storage_Session()); $adapter = new Zend_Auth_Adapter_DbTable($db, 'user', 'Email', 'password', 'md5(?)'); $adapter->setIdentity($email); $adapter->setCredential($passwd); $result = $auth->authenticate($adapter); return $result; }
public function logoutAction() { Zend_auth::getInstance()->clearIdentity(); $this->_forward('index', NULL, NULL, array('message' => 'You have been logged out. Come Again.')); }
public function logoutAction() { Zend_auth::getInstance()->clearIdentity(); $this->_redirect('index/index'); }