Esempio n. 1
0
 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");
     }
 }
Esempio n. 2
0
 public function authenticate($username, $password)
 {
     $modelUser = new Models_XMLUser();
     $result = $modelUser->authenticate($username, $password);
     if ($result->valid) {
         //Identity from DB is object
         $this->_identity = new stdClass();
         $this->_identity->userid = $result->user_info->userid;
         $this->_identity->username = $result->user_info->username;
         $this->_identity->userrole = $result->user_info->userrole;
         $this->_identity->controlblock = $result->user_info->controlblock;
         $this->_identity->name = $result->user_info->name;
         $storage = $this->getStorage();
         $zadmin_auth = $storage->create();
         $storage->write($this->_identity);
         Zing_Cookies::createCookies(self::COOKIE_ADMIN_AUTH_KEY, $zadmin_auth, 0);
         Zing_Cookies::createCookies(self::COOKIE_ADMIN_AUTH_ROLE, $result->user_info->userrole, 0);
         Zing_Cookies::createCookies(self::COOKIE_ADMIN_AUTH_SIG_KEY, md5($zadmin_auth . $result->user_info->userrole . ADMIN_AUTOREPORT_KEY), 0);
     }
     return $result->valid;
 }