Exemplo n.º 1
0
 /**
  * This function takes a username and sets the server in a state where
  * this user is logged in, and no longer requires an authentication check.
  *
  * @param string $userName
  */
 function autoLogin($userName)
 {
     $authBackend = new DAV\Auth\Backend\Mock();
     $authBackend->setPrincipal('principals/' . $userName);
     $this->authPlugin = new DAV\Auth\Plugin($authBackend);
     // If the auth plugin already exists, we're removing its hooks:
     if ($oldAuth = $this->server->getPlugin('auth')) {
         $this->server->removeListener('beforeMethod', [$oldAuth, 'beforeMethod']);
     }
     $this->server->addPlugin($this->authPlugin);
     // This will trigger the actual login procedure
     $this->authPlugin->beforeMethod(new Request(), new Response());
 }