Exemplo n.º 1
0
 public function getUser()
 {
     if (is_null($this->user)) {
         $d = new User_Domain_User();
         $this->user = $d->getByPersonId($this->id);
         if (is_null($this->user)) {
             $this->user = new User_Model_User();
         }
     }
     return $this->user;
 }
 public function indexAction()
 {
     if (User_Domain_User::isAllowed()) {
         $domain = new User_Domain_User();
         // if there is an id param search for this user
         // else get the authenticated user
         if ($this->_hasParam('id')) {
             $user = $domain->getById($this->_getParam('id'));
         } else {
             $user = $domain->getById(Zend_Auth::getInstance()->getIdentity()->id);
         }
         $this->view->user = $user;
     } else {
         $login = new Agana_Auth_Helper_Login();
         $login->redirectToLoginForm();
     }
 }
 public function indexAction()
 {
     // TODO implementar configuração para saber se pode ser chamado este install
     try {
         $ad = new App_Domain_Account();
         $app = new App_Model_Account();
         $appName = 'Winponta Software';
         $app = $ad->getByName($appName);
         if (!$app->getId()) {
             $app->setName($appName);
             $app->setEmail('*****@*****.**');
             $ad->setAccount($app);
             $app->setId($ad->createInstall());
         }
         $ud = new User_Domain_User();
         $ud->createSuperAdmin(null, $app);
         $login = new Agana_Auth_Helper_Login();
         $login->redirectToLoginForm();
     } catch (Exception $ae) {
         $this->_helper->flashMessenger->addMessage(array('error' => $ae->getMessage()));
     }
 }
Exemplo n.º 4
0
 public function updatePasswordAction()
 {
     if ($this->_hasParam("id")) {
         $id = $this->_getParam("id");
         //$update = $this->_isUserAllowed(User_Module_Acl::ACL_RESOURCE_USER, User_Module_Acl::ACL_RESOURCE_USER_PRIVILEGE_UPDATE);
         $update = Agana_Acl_Service::isAllowed(Zend_Auth::getInstance()->getIdentity()->acl_role_id, User_Module_Acl::ACL_RESOURCE_USER, User_Module_Acl::ACL_RESOURCE_USER_PRIVILEGE_UPDATE_PASSWORD);
         $isMe = $id == Zend_Auth::getInstance()->getIdentity()->id;
         if ($update || $isMe) {
             $request = $this->getRequest();
             $userDomain = new User_Domain_User(null);
             $user = $userDomain->getById($id);
             $form = new User_Form_Password(User_Form_User::ACTION_EDIT, $user);
             if ($request->isPost()) {
                 $data = $request->getPost();
                 if (isset($data['save'])) {
                     if ($form->isValid($data)) {
                         try {
                             $this->_updatePassword($data);
                             $msg = 'User updated';
                             $this->_helper->flashMessenger->addMessage(array('success' => $msg));
                             $param = null;
                             if ($id) {
                                 $param = array('id' => $id);
                             }
                             $this->_helper->redirector('index', 'profile', 'user', $param);
                         } catch (Exception $e) {
                             $this->_addSavingExceptionMessage($e);
                         }
                     } else {
                         $this->_addValidationMessage();
                     }
                 } else {
                     if (isset($data['cancel'])) {
                         $param = null;
                         if ($id) {
                             $param = array('id' => $id);
                         }
                         $this->_helper->redirector('index', 'profile', 'user', $param);
                     }
                 }
             }
             $this->view->form = $form;
             $this->view->user = $user;
         } else {
             $this->_helper->flashMessenger->addMessage(array('error' => 'You do not have permission to access this'));
             $param = null;
             if ($id) {
                 $param = array('id' => $id);
             }
             $this->_helper->redirector('index', 'profile', 'user', $param);
             return;
         }
     } else {
         $this->_helper->flashMessenger->addMessage(array('error' => 'Param id missing'));
         $this->_helper->redirector('index', 'profile', 'user');
         return;
     }
 }
Exemplo n.º 5
0
 protected function _processAuthentication($values)
 {
     $d = new User_Domain_User();
     $result = $d->authenticate($values['name'], $values['pwd']);
     return $result;
 }
 private function updatePassword($user, $data)
 {
     $userDomain = new User_Domain_User();
     $userDomain->setUser($user);
     try {
         return $userDomain->updatePwd(true);
     } catch (Agana_Exception $ae) {
         throw $ae;
     }
 }