public function changepassAction() { if ($this->getRequest()->isPost()) { $currpassword = $this->_request->getPost('currpassword'); $password = $this->_request->getPost('password'); $confirmpassword = $this->_request->getPost('confirmpassword'); $model_user = new AdminReportHandler(); $auth = Zing_Admin_Auth::getInstance(); $userId = $auth->getIdentity()->userid; try { if ($currpassword == '' || $password == '' || $confirmpassword == "") { $result['error'][] = "Enter required fields!"; } else { if ($password != $confirmpassword) { $result['error'][] = "Password and confirm password do not match"; } else { $user = $model_user->getAdmin($userId, $currpassword); if (count($user) != 1) { $result['error'][] = "Current password is wrong"; } else { $resultChangePass = $model_user->changePass($userId, $currpassword, $password); $result['success'] = true; } } } } catch (Exception $e) { $result['error'][] = "Unknown error"; } echo json_encode($result); die; } else { $this->view->container = $this->view->render("index/changepass.phtml"); } }
/** * Returns an instance of Zend_Auth * * Singleton pattern implementation * * @return Zing_Admin_Auth Provides a fluent interface */ public static function getInstance() { if (null === self::$_instance) { self::$_instance = new self(); } return self::$_instance; }
private function auth() { $auth = Zing_Admin_Auth::getInstance(); $this->view->name = $auth->getIdentity()->name; if ($auth->hasIdentity()) { $this->view->showSignOut = true; } else { $this->view->showSignOut = false; $this->_forward('signin', 'index'); } }
public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request) { $module = strtolower($request->getParam('module')); $controller = strtolower($request->getParam('controller')); $action = strtolower($request->getParam('action')); //echo $controller;exit; if ($controller == 'viewpointchangelog') { return; } // $auth = Zing_Admin_Auth::getInstance(); // if (!$auth->hasIdentity() && $controller != 'auth') { //START XML Check $auth = Zing_Admin_Auth::getInstance(); if (!$auth->hasIdentity() && $action != 'signin') { //END XML Check if (APP_ENV == 'production') { echo "Production: Access denied<br/>"; echo "<a href='signin'>Click here to log in</a>"; echo " and comeback later"; exit; } elseif (APP_ENV == 'development') { echo "Dev: Access denied<br/>"; echo "<a href='signin'>Click here to log in</a>"; echo " and comeback later"; exit; } } $identity = $auth->getIdentity(); // if ($module != 'meadmin' && $identity->usertype > 1) { // header('location: /meadmin'); // } // this part will be moved into helper after. $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer'); // setup view helpers $view = new Zend_View(); $viewRenderer->setView($view); if ($auth->hasIdentity()) { //$viewRenderer->view->msgLogin = "******"/admin/auth/logout\">[Logout]</a>"; } else { //BlockManager::setLayout('admin_login'); /* if ($module == 'admin') { BlockManager::setLayout('admin_login'); } else { BlockManager::setLayout('meadmin_login'); } */ //$viewRenderer->view->msgLogin = "******"; } }
public function changepassAction() { if ($this->getRequest()->isPost()) { $currpassword = $this->_request->getPost('currpassword'); $password = $this->_request->getPost('password'); $confirmpassword = $this->_request->getPost('confirmpassword'); $passlength = $this->_request->getPost('passlength'); $model_user = new Models_XMLUser(); $auth = Zing_Admin_Auth::getInstance(); $userId = $auth->getIdentity()->userid; $resultChangePass = $model_user->changePass($currpassword, $password, $confirmpassword, $passlength, $userId); $result['success'] = false; $result['error'] = array(); switch ($resultChangePass) { case SUCCESS: $result['success'] = true; break; case CHANGEPASS_EMPTY_CURR_PASS: $result['error'][] = "Current password is empty"; break; case CHANGEPASS_EMPTY_NEW_PASS: $result['error'][] = "New password is empty"; break; case CHANGEPASS_EMPTY_CONFIRM_PASS: $result['error'][] = "Confirm password is empty"; break; case CHANGEPASS_WRONG_OLD_PASS: $result['error'][] = "Current password is wrong"; break; case CHANGEPASS_CONFIRM_NOT_MATCH: $result['error'][] = "Password and confirm password do not match"; break; case CHANGEPASS_PASS_NOT_LENGTH_ENOUGH: $result['error'][] = "Password must be more than 5 characters"; break; default: $result['error'][] = "Unknown error"; break; } echo json_encode($result); die; } else { $this->view->container = $this->view->render("index/changepass.phtml"); } }
private function getUserID() { $auth = Zing_Admin_Auth::getInstance(); $userid = $auth->getIdentity()->userid; return $userid; }