Ejemplo n.º 1
0
 public function authenticateAction()
 {
     $debug = false;
     if ($debug) {
         echo "\n<div style=\"font-size: 90%;\">\n";
         echo "\n<div style=\"font-weight: bold;\">Config: </div>";
         print_r($this->getConfig());
         echo "\n<div style=\"font-weight: bold;\">GLOBAL SESSION: </div>";
         print_r($_SESSION);
         echo "</div>\n";
         die;
     }
     $redirect = 'login';
     $request = $this->getRequest();
     if ($request->isPost()) {
         // check authentication...
         $this->getAuthService()->getAdapter()->setIdentity($request->getPost('username'))->setCredential($request->getPost('password'));
         $user_session = new Container('user');
         if ($request->getPost('username') == null || $request->getPost('password') == "") {
             $user_session->message = 'Invalid username or password.';
             return $this->redirect()->toRoute($redirect);
         }
         $result = $this->getAuthService()->authenticate();
         if (!$result->isValid()) {
             /*
              * Is it possible that this user was approved
              * but has not yet accepted the user agreement?
              */
             $authUsersFactory = \_factory\authUsers::get_instance();
             $params = array();
             $params["user_email"] = $request->getPost('username');
             $params["user_password"] = \util\Password::md5_split_salt($request->getPost('password'));
             $auth_User = $authUsersFactory->get_row($params);
             if ($auth_User->user_enabled == 1 && $auth_User->user_verified == 1 && $auth_User->user_agreement_accepted != 1) {
                 return $this->msaagreement($auth_User);
             }
             $user_session->message = 'Invalid username or password.';
             return $this->redirect()->toRoute($redirect);
         } else {
             $redirect = 'private-exchange';
             if ($this->getAuthService()->getPublisherInfoID() != null) {
                 $redirect = 'publisher';
             }
             //check if it has rememberMe :
             if ($request->getPost('rememberme') == 1) {
                 $this->getSessionStorage()->setRememberMe(1);
                 //set storage again
                 $this->getAuthService()->setStorage($this->getSessionStorage());
             }
         }
     }
     return $this->redirect()->toRoute($redirect);
 }
Ejemplo n.º 2
0
 public function changepasswordAction()
 {
     $auth = $this->getServiceLocator()->get('AuthService');
     if (!$auth->hasIdentity()) {
         return $this->redirect()->toRoute('login');
     }
     $initialized = $this->initialize();
     if ($initialized !== true) {
         return $initialized;
     }
     $success_msg = null;
     $success_msg1 = null;
     $error_msg = null;
     $authUsers = new \model\authUsers();
     $authUsersFactory = \_factory\authUsers::get_instance();
     $PublisherInfo = new \model\PublisherInfo();
     $PublisherInfoFactory = \_factory\PublisherInfo::get_instance();
     $userData = $authUsersFactory->get_row(array("user_id" => $this->auth->getUserID()));
     $userRole = $this->auth->getRoles();
     $userRole = $userRole[0];
     $request = $this->getRequest();
     if ($request->isPost()) {
         $user_id = $request->getPost('user_id');
         $old_password = trim($request->getPost('old_password'));
         $password = trim($request->getPost('password'));
         $authUsers = $authUsersFactory->get_row_object(array("user_id" => $this->auth->getUserID()));
         $authUsers->user_id = $user_id;
         $authUsers->user_password = \util\Password::md5_split_salt($password);
         $authUsers->update_date = date("Y-m-d H:i:s");
         $userData = $authUsersFactory->get_row(array("user_id" => $authUsers->user_id));
         if ($userData->user_password == \util\Password::md5_split_salt($old_password)) {
             $authUsersFactory->saveUser($authUsers);
             $success_msg1 = 1;
         } else {
             $error_msg = "Old password is incorrect.";
         }
     }
     // check if user-role is memeber (publisher)
     if ($userRole == 'member') {
         $publisherData = $PublisherInfoFactory->get_row(array("PublisherInfoID" => $userData->PublisherInfoID));
         $userData['user_email'] = $publisherData['Email'];
         $userData['user_fullname'] = $publisherData['Name'];
     }
     $view = new ViewModel(array('dashboard_view' => 'account', 'user_identity' => $this->identity(), 'success_msg' => $success_msg, 'success_msg1' => $success_msg1, 'user_tab' => 'password', 'error_msg' => $error_msg, 'user_data' => $userData, 'user_id_list' => $this->user_id_list, 'user_identity' => $this->identity(), 'true_user_name' => $this->auth->getUserName(), 'header_title' => 'Account Settings', 'is_super_admin' => $this->is_super_admin, 'is_domain_admin' => $this->is_domain_admin, 'effective_id' => $this->auth->getEffectiveIdentityID(), 'impersonate_id' => $this->ImpersonateID));
     return $view->setTemplate('dashboard-manager/auth/changepassword.phtml');
 }