/**
  * Perform impersonation.
  * 
  * @return boolean TRUE if success, FALSE otherwise.
  */
 protected function ImpersonateUser()
 {
     $this->initialize();
     if ($this->is_super_admin || $this->is_domain_admin) {
         // TODO: Hummm... ANY admin can login as ANY OTHER admin, even if the pull down does not allow.
         $this->auth->impersonateUserID($this->getRequest()->getQuery('userid'));
         return TRUE;
     }
     // If debugging and user has no permission, then die to say so.
     if ($this->debug && !$this->is_super_admin) {
         die("You do not have permission to access this page");
     }
     return FALSE;
 }
Exemplo n.º 2
0
 /**
  * Setup the additional services attached to this module, particularly authentication.
  * @return multitype:multitype:NULL  |\auth\UserIdentityProvider
  */
 public function getServiceConfig()
 {
     return array('factories' => array('AuthService' => function ($sm) {
         //My assumption, you've alredy set dbAdapter
         //and has users table with columns : user_name and pass_word
         //that password hashed with md5
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $dbTableAuthAdapter = new DbTableAuthAdapter($dbAdapter, 'auth_userslogin', 'user_email', 'user_password', 'MD5_SPLIT_SALT(?,`user_password_salt`)');
         // Use SALTED MD5 passwords when possible.
         // IMPORTANT: UserIdentityProvider is needed for ZFC-RBAC access control,
         //            which REQUIRES a DB to authenticate!
         $authService = new UserIdentityProvider();
         $authService->setAdapter($dbTableAuthAdapter);
         $authService->setStorage(new UserAuthenticationStorage('nginad'));
         $authService->setConfigHandle($sm->get('config'));
         // If debugging is set, output the debugging data.
         // NOTE: Verbose may break browser session handling!
         if ($sm->get('config')['system']['debug']) {
             echo "\n<div style=\"font-size: 90%;\">\n";
             if ($sm->get('config')['system']['debug_verbose']) {
                 echo "\n<div style=\"font-weight: bold;\">Config: </div>";
                 print_r($sm->get('config'));
                 print_r(get_class_methods($sm));
                 print_r($sm->getRegisteredServices());
             }
             echo "\n<div style=\"font-weight: bold;\">GLOBAL SESSION: </div>";
             print_r($_SESSION);
             echo "</div>\n";
         }
         return $authService;
     }, 'mail.transport' => function ($sm) {
         $config = $sm->get('Config');
         if ($config['mail']['transport']['smtp']) {
             $transport = new Smtp();
             $transport->setOptions(new SmtpOptions($config['mail']['transport']['options']));
         } else {
             $transport = new Sendmail();
         }
         return $transport;
     }));
 }