Esempio n. 1
0
 public function onBootstrap(MvcEvent $e)
 {
     /* @var $sessionManager SessionManager */
     $serviceLocator = $e->getApplication()->getServiceManager();
     $sessionManager = $serviceLocator->get('Zend\\Session\\SessionManager');
     $sessionManager->setSaveHandler($serviceLocator->get('Zend\\Session\\SaveHandler\\SaveHandlerInterface'));
     AbstractContainer::setDefaultManager($sessionManager);
 }
Esempio n. 2
0
 /**
  * Authentificate user by username/password pair
  *
  * @param string $username
  * @param string $password
  * @param boolean $remember
  * @return \Zend\Authentication\Result
  * @throws \Exception
  */
 public function authentificate($username, $password, $remember = false)
 {
     $adapter = $this->authService->getAdapter();
     if (!$adapter instanceof \Zend\Authentication\Adapter\DbTable) {
         throw new \Exception('invalid auth adapter type');
     }
     $adapter->setIdentity($username)->setCredential($password);
     $result = $this->authService->authenticate();
     if ($result->getCode() == \Zend\Authentication\Result::SUCCESS) {
         if ($remember) {
             $this->sessionContainer->getManager()->rememberMe();
         }
         $this->sessionContainer->userEntity = (array) $adapter->getResultRowObject();
     } else {
         $this->sessionContainer->userEntity = null;
     }
     return $result;
 }
Esempio n. 3
0
 protected function setUp()
 {
     $storage = $this->getMock('Zend\\Authentication\\Storage\\Session');
     $this->storage = $storage;
     $authEvent = $this->getMock('ZfcUser\\Authentication\\Adapter\\AdapterChainEvent');
     $this->authEvent = $authEvent;
     $options = $this->getMock('ZfcUser\\Options\\ModuleOptions');
     $this->options = $options;
     $mapper = $this->getMock('ZfcUser\\Mapper\\User');
     $this->mapper = $mapper;
     $user = $this->getMock('ZfcUser\\Entity\\User');
     $this->user = $user;
     $this->db = new Db();
     $this->db->setStorage($this->storage);
     $sessionManager = $this->getMock('Zend\\Session\\SessionManager');
     \Zend\Session\AbstractContainer::setDefaultManager($sessionManager);
 }
Esempio n. 4
0
 protected function setUp()
 {
     $this->options = $this->getMock('ZfcUser\\Options\\ModuleOptions');
     $this->mapper = $this->getMockForAbstractClass('ZfcUser\\Mapper\\UserInterface');
     $this->user = $this->getMockForAbstractClass('ZfcUser\\Entity\\UserInterface');
     $this->storage = $this->getMockForAbstractClass('Zend\\Authentication\\Storage\\StorageInterface');
     $this->authEvent = $this->getMock('ZfcUser\\Authentication\\Adapter\\AdapterChainEvent');
     $this->bcrypt = $this->getMock('Zend\\Crypt\\Password\\Bcrypt');
     $this->hydrator = $this->getMockForAbstractClass('ZfcUser\\Mapper\\HydratorInterface');
     $this->hydrator->expects($this->any())->method('getCryptoService')->will($this->returnValue($this->bcrypt));
     $this->services = $this->getMock('Zend\\ServiceManager\\ServiceManager');
     $this->services->expects($this->any())->method('get')->will($this->returnValueMap(array(array('zfcuser_module_options', true, $this->options), array('zfcuser_user_mapper', true, $this->mapper), array('zfcuser_user_hydrator', true, $this->hydrator))));
     $this->db = new Db();
     $this->db->setServiceManager($this->services);
     $this->db->setStorage($this->storage);
     $sessionManager = $this->getMock('Zend\\Session\\SessionManager');
     \Zend\Session\AbstractContainer::setDefaultManager($sessionManager);
 }