Exemplo n.º 1
0
 /**
  * get instance
  *
  *
  * @return Auth_Model_UserMapper
  */
 public static function getInstance()
 {
     if (self::$_instance === null) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Exemplo n.º 2
0
 public function isValid($value, $context = null)
 {
     $result = true;
     $isPassedPassword = Auth_Model_UserMapper::getInstance()->checkPassedUserPaswwords($this->_data['id'], $value);
     if ($isPassedPassword) {
         $this->_error(self::PASS_EXISTS);
         $result = false;
     }
     return $result;
 }
Exemplo n.º 3
0
 /**
  * @throws Zend_Auth_Adapter_Exception If authentication can not be establish
  * @return Zend_Auth_Result
  */
 public function authenticate()
 {
     $this->_admin = new Auth_Model_User();
     //invalid username
     if (!Auth_Model_UserMapper::getInstance()->findByCredentials($this->_auth, $this->_admin)) {
         return $this->createResult(Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND, self::NOT_FOUND_MESSAGE);
     }
     //invalid pass
     if ($this->_admin->get_password() != md5($this->_password)) {
         return $this->createResult(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID, self::BAD_PW_MSG);
     }
     //not active
     if ($this->_admin->get_status() != 'active') {
         return $this->createResult(Zend_Auth_Result::FAILURE_UNCATEGORIZED, self::STATUS_NOT_ACTIVE);
     }
     return $this->createResult(Zend_Auth_Result::SUCCESS);
 }
Exemplo n.º 4
0
 public function isValid($value, $context = null)
 {
     $result = true;
     $this->_value = $value;
     $user = new Auth_Model_User();
     if (Auth_Model_UserMapper::getInstance()->find($this->_data['id'], $user)) {
         $old_password = $user->get_password();
         if (md5($this->_data['old_password']) != $old_password) {
             $this->_error(self::PASS_EXISTS);
             $result = false;
         }
     } else {
         $this->_error(self::PASS_EXISTS);
         $result = false;
     }
     return $result;
 }
Exemplo n.º 5
0
 public function indexAction()
 {
     //get user object
     $user = new Auth_Model_User();
     Auth_Model_UserMapper::getInstance()->find($this->_admin->get_id(), $user);
     $bootstrap = $this->getInvokeArg('bootstrap');
     $config = $bootstrap->getOptions();
     $this->view->clientId = isset($config['googleapi']['analitycs']['clientId']) && $config['googleapi']['analitycs']['clientId'] != '' ? $config['googleapi']['analitycs']['clientId'] : '';
     //store dashbord
     if ($this->getRequest()->isXmlHttpRequest() && $this->getRequest()->isPost()) {
         $dashboard = $this->_getParam('dashboard');
         if (!isset($dashboard)) {
             $dashboard = array();
         }
         $userData = $user->get_data();
         $userData['dashboard'] = $dashboard;
         $user->set_data($userData);
         $user->set_password(null);
         Auth_Model_UserMapper::getInstance()->save($user);
         return $this->getHelper('json')->direct(array('success' => true));
     }
     $this->view->widgetClasses = array();
     $this->view->widgetJsFiles = array();
     $this->view->widgetCssFiles = array();
     //list modules
     $modules = Application_Model_ModuleMapper::getInstance()->fetchAll(array('status' => 'active'));
     /* @var $module Application_Model_Module */
     foreach ($modules as $module) {
         $widgets = $module->get_data('widgets');
         if (!isset($widgets)) {
             continue;
         }
         foreach ($widgets as $widgetClass => $widgetArr) {
             $this->view->widgetClasses[] = $widgetClass;
             foreach ($widgetArr['jsFiles'] as $jsFile) {
                 $this->view->widgetJsFiles[] = $jsFile;
             }
             foreach ($widgetArr['cssFiles'] as $cssFile) {
                 $this->view->widgetCssFiles[] = $cssFile;
             }
         }
     }
     //get configured user's dashboard
     $userDashboard = $user->get_data('dashboard');
     if (!isset($userDashboard)) {
         $userDashboard = array('region1' => array('widgets' => array()), 'region2' => array('widgets' => array()));
         $i = 0;
         foreach ($this->view->widgetClasses as $widgetClass) {
             $widgetArr = array('componentClass' => $widgetClass, 'settings' => array());
             $regionIndex = $i % 2 + 1;
             $userDashboard['region' . $regionIndex]['widgets'][] = $widgetArr;
             $i++;
         }
     }
     $this->view->userDashboard = $userDashboard;
 }
Exemplo n.º 6
0
 private function savePassHistory($id)
 {
     $oldUser = new Auth_Model_User();
     if (!Auth_Model_UserMapper::getInstance()->find($id, $oldUser)) {
         throw new Exception("User not found");
     }
     Auth_Model_UserMapper::getInstance()->getInstance()->saveHistoryUserPassword($oldUser);
 }