Exemplo n.º 1
0
 /**
  * If the admin path matches, initialize the Login plugin configuration and set the admin
  * as active.
  */
 public function login()
 {
     // Check for Pro version is enabled
     if ($this->config->get('plugins.admin-pro.enabled')) {
         $this->active = false;
         return;
     }
     $route = $this->config->get('plugins.admin.route');
     if (!$route) {
         return;
     }
     $this->grav['debugger']->addMessage("Admin Basic");
     $this->base = '/' . trim($route, '/');
     $this->uri = $this->grav['uri'];
     // Only activate admin if we're inside the admin path.
     if (substr($this->uri->route(), 0, strlen($this->base)) == $this->base) {
         // Change login behavior.
         $this->config->set('plugins.login', $this->config->get('plugins.admin.login'));
         $this->config->set('plugins.login.session.path', $this->uri->rootUrl(false) . $this->base);
         $this->config->set('plugins.login.session.name', 'grav_admin');
         $this->active = true;
     }
 }
Exemplo n.º 2
0
 public function testRootUrl()
 {
     //Without explicitly adding the root path via `initializeWithUrlAndRootPath`,
     //tests always default to the base empty root path
     $this->uri->initializeWithURL('http://localhost/a-page')->init();
     $this->assertSame('http://localhost', $this->uri->rootUrl(true));
     $this->uri->initializeWithURL('http://localhost:8080/a-page')->init();
     $this->assertSame('http://localhost:8080', $this->uri->rootUrl(true));
     $this->uri->initializeWithURL('http://foobar.it:80/a-page')->init();
     $this->assertSame('http://foobar.it', $this->uri->rootUrl(true));
     $this->uri->initializeWithURL('https://google.com/a-page/xxx')->init();
     $this->assertSame('http://google.com', $this->uri->rootUrl(true));
     $this->uri->initializeWithUrlAndRootPath('https://localhost/grav/page-foo', '/grav')->init();
     $this->assertSame('/grav', $this->uri->rootUrl());
     $this->assertSame('http://localhost/grav', $this->uri->rootUrl(true));
 }