public function testGetIpAddress()
 {
     $request = new Request($this->container, array(), array(), array(), array(), array());
     $this->assertEquals('Unknown', $request->getIpAddress());
     $request = new Request($this->container, array('HTTP_X_FORWARDED_FOR' => '192.168.0.1,127.0.0.1'), array(), array(), array(), array());
     $this->assertEquals('192.168.0.1', $request->getIpAddress());
     $request = new Request($this->container, array('REMOTE_ADDR' => '192.168.0.1'), array(), array(), array(), array());
     $this->assertEquals('192.168.0.1', $request->getIpAddress());
     $request = new Request($this->container, array('REMOTE_ADDR' => ''), array(), array(), array(), array());
     $this->assertEquals('Unknown', $request->getIpAddress());
 }
Esempio n. 2
0
 public function onSuccess(AuthEvent $event)
 {
     $this->lastLogin->create($event->getAuthType(), $event->getUserId(), Request::getIpAddress(), Request::getUserAgent());
 }
Esempio n. 3
0
 /**
  * Create remember me session if necessary
  *
  * @access private
  * @param  array   $values           Form values
  */
 private function createRememberMeSession(array $values)
 {
     if (REMEMBER_ME_AUTH && !empty($values['remember_me'])) {
         $credentials = $this->backend('rememberMe')->create($this->userSession->getId(), Request::getIpAddress(), Request::getUserAgent());
         $this->backend('rememberMe')->writeCookie($credentials['token'], $credentials['sequence'], $credentials['expiration']);
     }
 }