Exemplo n.º 1
0
 /**
  * event function for cpanel login
  * @param object $evctl
  * @return void
  */
 public function eventLogin(\EventControler $evctl)
 {
     $login_success = false;
     if ($evctl->user_name != '' && $evctl->user_password != '') {
         $qry = "\n\t\t\tselect cu.*,c.firstname,c.lastname,c.contact_avatar from " . $this->getTable() . " cu\n\t\t\tjoin contacts c on c.idcontacts = cu.idcontacts\n\t\t\twhere \n\t\t\tcu.`email` = ? \n\t\t\tAND cu.`password` = ?\n\t\t\tAND c.deleted = 0\n\t\t\tAND c.portal_user = 1\n\t\t\t";
         $this->query($qry, array($evctl->user_name, MD5($evctl->user_password)));
         if ($this->getNumRows() == 1) {
             $this->next();
             $idcpanel_user = $this->idcpanel_user;
             $login_success = true;
         } elseif ($this->getNumRows() > 1) {
             $msg = _('Looks like you have multiple login for the customer portal for different organization, please ask the provider to reset the password for one');
         } else {
             $msg = _('Authentication failed ! Invalid login details');
         }
         if (true === $login_success) {
             $this->set_subordinates($this->idcpanel_user, $this->idorganization);
             $_SESSION["do_cpanel_action_permission"]->load_cpanel_user_modules($this->idorganization);
             $this->sessionPersistent("do_cpaneluser", "logout.php", TTL_LONG);
             if (!is_object($_SESSION["do_global_settings"])) {
                 $do_global_settings = new \CRMGlobalSettings();
                 $do_global_settings->sessionPersistent("do_global_settings", "logout.php", TTL);
             }
             $dis = new \Display($evctl->goto);
             //@see view/login_view
             if ((int) $evctl->sqrecord > 0) {
                 $dis->addParam("sqrecord", (int) $evctl->sqrecord);
             }
             $evctl->setDisplayNext($dis);
         } else {
             $_SESSION["do_cpanel_messages"]->set_message('error', $msg);
         }
     } else {
         $_SESSION["do_cpanel_messages"]->set_message('error', _('Missing email or password for authentication'));
     }
 }
Exemplo n.º 2
0
 /**
  * Event function for login
  * @param object $evctl 
  */
 public function eventLogin(EventControler $evctl)
 {
     $login_success = false;
     if ($evctl->user_name != '' && $evctl->user_password != '') {
         $qry = "\n\t\t\tselect * from " . $this->getTable() . " \n\t\t\twhere `user_name` = ? AND `password` = ?";
         $this->query($qry, array($evctl->user_name, MD5($evctl->user_password)));
         if ($this->getNumRows() == 1) {
             $this->next();
             // fetch the first row
             $iduser = $this->iduser;
             if ($this->is_active != 'Yes') {
                 $_SESSION["do_crm_messages"]->set_message('error', _('The account is not active, please ask your admin to check this !'));
             } else {
                 $login_success = true;
             }
         } elseif ($this->getNumRows() > 1) {
             $_SESSION["do_crm_messages"]->set_message('info', _('This is not your fault, you have entered correct login details but some other user has same login details, which is very unlikely. Please ask your admin to change the username or password. !'));
         } else {
             $_SESSION["do_crm_messages"]->set_message('error', _('Wrong login details !'));
         }
     } else {
         $_SESSION["do_crm_messages"]->set_message('error', _('Please enter a valid username and password !'));
     }
     if ($login_success === true) {
         $this->sessionPersistent("do_user", "logout.php", TTL_LONG);
         $this->set_user_crm_privileges();
         $subordinate_users = $this->get_subordinate_users_by_iduser($iduser);
         $this->set_subordinate_users($subordinate_users);
         $do_mod_datashare_permission = new ModuleToDatashareRelation();
         $this->set_module_data_share_permissions($do_mod_datashare_permission->get_all_datashare_permissions());
         $dis = new Display($evctl->goto);
         //@see view/login_view
         if ((int) $evctl->sqrecord > 0) {
             $dis->addParam("sqrecord", (int) $evctl->sqrecord);
         }
         //do login audit
         $do_login_audit = new LoginAudit();
         $do_login_audit->do_login_audit();
         //load the global setting object
         if (!is_object($_SESSION["do_global_settings"])) {
             $do_global_settings = new CRMGlobalSettings();
             $do_global_settings->sessionPersistent("do_global_settings", "logout.php", TTL);
         }
         //update the unseen feed to viewed = 1 on login
         $do_livefeed_display = new LiveFeedDisplay();
         $do_livefeed_display->set_feed_viewed_onlogin($iduser);
         //finally do the re-direct
         $evctl->setDisplayNext($dis);
     }
 }