Ejemplo n.º 1
0
 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 createNewAction()
 {
     if ($this->_hasParam('id') && $this->_hasParam('key')) {
         $userDomain = new \User_Domain_User();
         $user = $userDomain->getById($this->_getParam('id'));
         if ($user) {
             if ($userDomain->isValidResetPasswordKey($user, $this->_getParam('key'))) {
                 $form = new \User_Form_Password(User_Form_Password::ACTION_EDIT, $user);
                 $this->view->form = $form;
                 $request = $this->getRequest();
                 if ($request->isPost()) {
                     $data = $request->getPost();
                     $form->populate($data);
                     if ($form->save->isChecked()) {
                         if ($form->isValid($data)) {
                             try {
                                 $this->updatePassword($data);
                                 $msg = 'Password updated, please login';
                                 $this->_helper->flashMessenger->addMessage(array('success' => $msg));
                                 $this->_helper->redirector('index', 'auth', 'user');
                             } catch (Exception $e) {
                                 $this->addSavingExceptionMessage($e);
                             }
                         } else {
                             $this->_helper->flashMessenger->addMessage(array('validation' => 'Some problem with fields content.'));
                         }
                     } else {
                         $this->_helper->redirector('index', 'auth', 'user');
                     }
                 }
             } else {
                 $this->redirectInvalidResetLink();
             }
         } else {
             // if not $user
             $this->redirectInvalidResetLink();
         }
     } else {
         // if has param ID
         $msg = 'Param "id" or "key" is missing';
         $this->_helper->flashMessenger->addMessage(array('error' => $msg));
         $this->_helper->redirector('index', 'reset-password', 'user');
     }
 }
Ejemplo n.º 3
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;
     }
 }